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.8.1 spec/models/order_item_spec.rb
effective_orders-1.8.0 spec/models/order_item_spec.rb
effective_orders-1.7.5 spec/models/order_item_spec.rb
effective_orders-1.7.4 spec/models/order_item_spec.rb
effective_orders-1.7.3 spec/models/order_item_spec.rb
effective_orders-1.7.2 spec/models/order_item_spec.rb
effective_orders-1.7.1 spec/models/order_item_spec.rb
effective_orders-1.7.0 spec/models/order_item_spec.rb
effective_orders-1.6.6 spec/models/order_item_spec.rb
effective_orders-1.6.5 spec/models/order_item_spec.rb
effective_orders-1.6.4 spec/models/order_item_spec.rb
effective_orders-1.6.3 spec/models/order_item_spec.rb
effective_orders-1.6.1 spec/models/order_item_spec.rb
effective_orders-1.6.0 spec/models/order_item_spec.rb
effective_orders-1.5.9 spec/models/order_item_spec.rb
effective_orders-1.5.8 spec/models/order_item_spec.rb
effective_orders-1.5.7 spec/models/order_item_spec.rb
effective_orders-1.5.5 spec/models/order_item_spec.rb
effective_orders-1.5.4 spec/models/order_item_spec.rb
effective_orders-1.5.3 spec/models/order_item_spec.rb