mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Rename OrderCycle#distributed_variants_by to variants_distributed_by
This commit is contained in:
@@ -92,7 +92,7 @@ class OrderCycle < ActiveRecord::Base
|
||||
self.exchanges.where(:sender_id => self.coordinator).map(&:variants).flatten.uniq
|
||||
end
|
||||
|
||||
def distributed_variants_by(distributor)
|
||||
def variants_distributed_by(distributor)
|
||||
self.exchanges.where(:sender_id => self.coordinator, :receiver_id => distributor).
|
||||
map(&:variants).flatten.uniq
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class DistributionChangeValidator
|
||||
|
||||
def variants_available_for_distribution(distributor, order_cycle)
|
||||
product_distribution_variants = distributor.andand.product_distribution_variants || []
|
||||
order_cycle_variants = order_cycle.andand.distributed_variants_by(distributor) || []
|
||||
order_cycle_variants = order_cycle.andand.variants_distributed_by(distributor) || []
|
||||
|
||||
product_distribution_variants + order_cycle_variants
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ describe DistributionChangeValidator do
|
||||
it "finds variants distributed by product distribution" do
|
||||
v = double(:variant)
|
||||
d = double(:distributor, product_distribution_variants: [v])
|
||||
oc = double(:order_cycle, distributed_variants_by: [])
|
||||
oc = double(:order_cycle, variants_distributed_by: [])
|
||||
|
||||
subject.variants_available_for_distribution(d, oc).should == [v]
|
||||
end
|
||||
@@ -45,7 +45,7 @@ describe DistributionChangeValidator do
|
||||
d = double(:distributor, product_distribution_variants: [])
|
||||
oc = double(:order_cycle)
|
||||
|
||||
oc.should_receive(:distributed_variants_by).with(d) { [v] }
|
||||
oc.should_receive(:variants_distributed_by).with(d) { [v] }
|
||||
|
||||
subject.variants_available_for_distribution(d, oc).should == [v]
|
||||
end
|
||||
|
||||
@@ -193,7 +193,7 @@ describe OrderCycle do
|
||||
end
|
||||
|
||||
it "reports on the variants distributed by a particular distributor" do
|
||||
@oc.distributed_variants_by(@d2).should == [@p1.master]
|
||||
@oc.variants_distributed_by(@d2).should == [@p1.master]
|
||||
end
|
||||
|
||||
it "reports on the products exchanged" do
|
||||
|
||||
Reference in New Issue
Block a user