Sha256: 6d58703a07dff9bf197da0f6f8f657fe17530cf475332f550f2ed6b0b334f4ea

Contents?: true

Size: 969 Bytes

Versions: 64

Compression:

Stored size: 969 Bytes

Contents

require 'spec_helper'

# # Attributes
describe Effective::OrderItem do
  let(:order) { FactoryGirl.create(:order) }
  let(:order_item) { FactoryGirl.create(:order_item) }

  describe 'validations' do
    it 'is invalid without required fields' do
      order_item = Effective::OrderItem.new()
      order_item.valid?.should eq false

      order_item.errors[:title].present?.should eq true
      order_item.errors[:quantity].present?.should eq true
      order_item.errors[:tax_exempt].present?.should eq true
      order_item.errors[:purchasable].present?.should eq true
    end
  end

  describe 'scopes' do
    it 'is included in the Sold scope when order is purchased' do
      order.purchase!('from a test')
      (order.order_items.size > 0).should eq true

      sold_items = Effective::OrderItem.sold.to_a
      sold_items.size.should eq order.order_items.size

      order.order_items.each { |oi| sold_items.include?(oi).should eq true }
    end

  end



end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
effective_orders-1.3.5 spec/models/order_item_spec.rb
effective_orders-1.3.4 spec/models/order_item_spec.rb
effective_orders-1.3.3 spec/models/order_item_spec.rb
effective_orders-1.3.2 spec/models/order_item_spec.rb
effective_orders-1.3.1 spec/models/order_item_spec.rb
effective_orders-1.3.0 spec/models/order_item_spec.rb
effective_orders-1.2.13 spec/models/order_item_spec.rb
effective_orders-1.2.12 spec/models/order_item_spec.rb
effective_orders-1.2.11 spec/models/order_item_spec.rb
effective_orders-1.2.10 spec/models/order_item_spec.rb
effective_orders-1.2.9 spec/models/order_item_spec.rb
effective_orders-1.2.8 spec/models/order_item_spec.rb
effective_orders-1.2.7 spec/models/order_item_spec.rb
effective_orders-1.2.6 spec/models/order_item_spec.rb
effective_orders-1.2.5 spec/models/order_item_spec.rb
effective_orders-1.2.4 spec/models/order_item_spec.rb
effective_orders-1.2.3 spec/models/order_item_spec.rb
effective_orders-1.2.2 spec/models/order_item_spec.rb
effective_orders-1.2.1 spec/models/order_item_spec.rb
effective_orders-1.2.0 spec/models/order_item_spec.rb