Fix specs: stale data

This commit is contained in:
Rohan Mitchell
2014-03-12 13:34:05 +11:00
parent 4d8a23346c
commit a8373b7bef
3 changed files with 8 additions and 1 deletions

View File

@@ -23,7 +23,7 @@ class OrderCycle < ActiveRecord::Base
scope :distributing_product, lambda { |product|
joins(:exchanges => :variants).
merge(Exchange.outgoing).
where('spree_variants.id IN (?)', product.variants_including_master.map(&:id)).
where('spree_variants.id IN (?)', product.variants_including_master.pluck(:id)).
select('DISTINCT order_cycles.*') }
scope :with_distributor, lambda { |distributor|

View File

@@ -124,6 +124,7 @@ describe Exchange do
p = create(:simple_product)
ex = create(:exchange)
ex.variants << p.master
p.reload
Exchange.with_product(p).should == [ex]
end
@@ -133,6 +134,7 @@ describe Exchange do
v = create(:variant, product: p)
ex = create(:exchange)
ex.variants << v
p.reload
Exchange.with_product(p).should == [ex]
end

View File

@@ -63,6 +63,8 @@ describe OrderCycle do
p = create(:product)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d], variants: [p.master])
p.reload
OrderCycle.distributing_product(p).should == [oc]
end
@@ -71,6 +73,8 @@ describe OrderCycle do
v = create(:variant, product: p)
d = create(:distributor_enterprise)
oc = create(:simple_order_cycle, distributors: [d], variants: [v])
p.reload
OrderCycle.distributing_product(p).should == [oc]
end
@@ -80,6 +84,7 @@ describe OrderCycle do
oc = create(:simple_order_cycle)
ex = create(:exchange, order_cycle: oc, sender: s, receiver: oc.coordinator)
ex.variants << p.master
p.reload
OrderCycle.distributing_product(p).should == []
end