mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-04 02:31:33 +00:00
DistributionChangeValidator finds variants distributed by product distribution when order cycle is nil
This commit is contained in:
@@ -14,7 +14,10 @@ class DistributionChangeValidator
|
||||
end
|
||||
|
||||
def variants_available_for_distribution(distributor, order_cycle)
|
||||
distributor.distributed_variants + order_cycle.distributed_variants_by(distributor)
|
||||
product_distribution_variants = distributor.distributed_variants
|
||||
order_cycle_variants = order_cycle.andand.distributed_variants_by(distributor) || []
|
||||
|
||||
product_distribution_variants + order_cycle_variants
|
||||
end
|
||||
|
||||
def distributor_available_for?(product)
|
||||
|
||||
@@ -33,6 +33,13 @@ describe DistributionChangeValidator do
|
||||
subject.variants_available_for_distribution(d, oc).should == [v]
|
||||
end
|
||||
|
||||
it "finds variants distributed by product distribution when order cycle is nil" do
|
||||
v = double(:variant)
|
||||
d = double(:distributor, distributed_variants: [v])
|
||||
|
||||
subject.variants_available_for_distribution(d, nil).should == [v]
|
||||
end
|
||||
|
||||
it "finds variants distributed by order cycle" do
|
||||
v = double(:variant)
|
||||
d = double(:distributor, distributed_variants: [])
|
||||
|
||||
Reference in New Issue
Block a user