From 59935619e345913bb0716de970a8edaa2c63a519 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 15 Nov 2013 14:34:05 +1100 Subject: [PATCH] Rename OrderCycle#distributed_variants_by to variants_distributed_by --- app/models/order_cycle.rb | 2 +- lib/open_food_network/distribution_change_validator.rb | 2 +- .../open_food_network/distribution_change_validator_spec.rb | 4 ++-- spec/models/order_cycle_spec.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 2085f16af6..6f4b70476d 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -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 diff --git a/lib/open_food_network/distribution_change_validator.rb b/lib/open_food_network/distribution_change_validator.rb index 23cae39a23..6f7edc2c0f 100644 --- a/lib/open_food_network/distribution_change_validator.rb +++ b/lib/open_food_network/distribution_change_validator.rb @@ -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 diff --git a/spec/lib/open_food_network/distribution_change_validator_spec.rb b/spec/lib/open_food_network/distribution_change_validator_spec.rb index ac5785b854..7e2a4b3274 100644 --- a/spec/lib/open_food_network/distribution_change_validator_spec.rb +++ b/spec/lib/open_food_network/distribution_change_validator_spec.rb @@ -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 diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index 719d89e620..5c5f204f4c 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -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