diff --git a/lib/open_food_web/split_products_by_distribution.rb b/lib/open_food_web/split_products_by_distribution.rb index 736a5b2fea..732dabf0de 100644 --- a/lib/open_food_web/split_products_by_distribution.rb +++ b/lib/open_food_web/split_products_by_distribution.rb @@ -8,7 +8,7 @@ module OpenFoodWeb # If a distributor is provided, split the list of products into local (at that # distributor) and remote (at another distributor). If a distributor is not # provided, perform no split. - def split_products_by_distribution(products, distributor) + def split_products_by_distribution(products, distributor, order_cycle) products_local = products_remote = nil if distributor diff --git a/spec/lib/open_food_web/split_products_by_distribution_spec.rb b/spec/lib/open_food_web/split_products_by_distribution_spec.rb index fc588106a7..7581ae3fd4 100644 --- a/spec/lib/open_food_web/split_products_by_distribution_spec.rb +++ b/spec/lib/open_food_web/split_products_by_distribution_spec.rb @@ -5,26 +5,30 @@ describe OpenFoodWeb::SplitProductsByDistribution do let(:subject) { products_splitter.new } - it "does nothing when no distributor is selected" do + it "does nothing when no distributor or order cycle is selected" do orig_products = (1..3).map { |i| build(:product) } - products, products_local, products_remote = subject.split_products_by_distribution orig_products, nil + products, products_local, products_remote = subject.split_products_by_distribution orig_products, nil, nil products.should == orig_products products_local.should be_nil products_remote.should be_nil end - it "splits products when a distributor is selected" do + it "splits products by product distribution when a distributor is selected" do d1 = build(:distributor_enterprise) d2 = build(:distributor_enterprise) orig_products = [build(:product, :distributors => [d1]), build(:product, :distributors => [d2])] - products, products_local, products_remote = subject.split_products_by_distribution orig_products, d1 + products, products_local, products_remote = subject.split_products_by_distribution orig_products, d1, nil products.should be_nil products_local.should == [orig_products[0]] products_remote.should == [orig_products[1]] end + + it "splits products by order cycle distribution when a distributor is selected" + it "splits products by order cycle when an order cycle is selected" + it "splits products by both order cycle and distributor when both are selected" end