Rename OrderCycle#distributed_variants_by to variants_distributed_by

This commit is contained in:
Rohan Mitchell
2013-11-15 14:34:05 +11:00
parent 52b6c33aaa
commit 59935619e3
4 changed files with 5 additions and 5 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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