mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Fix specs: stale data
This commit is contained in:
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user