Sha256: 9e301224505c1cd4061f3ef1d5553292c3e06e9635c97395f81a87a25e6b419f

Contents?: true

Size: 954 Bytes

Versions: 25

Compression:

Stored size: 954 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!
      (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

25 entries across 25 versions & 1 rubygems

Version Path
effective_orders-3.0.0 spec/models/order_item_spec.rb
effective_orders-2.2.4 spec/models/order_item_spec.rb
effective_orders-2.2.3 spec/models/order_item_spec.rb
effective_orders-2.2.2 spec/models/order_item_spec.rb
effective_orders-2.2.1 spec/models/order_item_spec.rb
effective_orders-2.2.0 spec/models/order_item_spec.rb
effective_orders-2.1.17 spec/models/order_item_spec.rb
effective_orders-2.1.16 spec/models/order_item_spec.rb
effective_orders-2.1.15 spec/models/order_item_spec.rb
effective_orders-2.1.14 spec/models/order_item_spec.rb
effective_orders-2.1.13 spec/models/order_item_spec.rb
effective_orders-2.1.12 spec/models/order_item_spec.rb
effective_orders-2.1.10 spec/models/order_item_spec.rb
effective_orders-2.1.9 spec/models/order_item_spec.rb
effective_orders-2.1.8 spec/models/order_item_spec.rb
effective_orders-2.1.7 spec/models/order_item_spec.rb
effective_orders-2.1.6 spec/models/order_item_spec.rb
effective_orders-2.1.5 spec/models/order_item_spec.rb
effective_orders-2.1.4 spec/models/order_item_spec.rb
effective_orders-2.1.3 spec/models/order_item_spec.rb