mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
WIP: Add spec for in_distributor
This commit is contained in:
@@ -21,11 +21,6 @@ module Spree
|
||||
end
|
||||
|
||||
describe "scopes" do
|
||||
# in_distributor
|
||||
# - shows products in product distribution
|
||||
# - shows products in order cycle distribution
|
||||
# - doesn't show products not in either
|
||||
#
|
||||
# in_supplier_or_distributor
|
||||
# - shows products in supplier
|
||||
# - shows products in product distribution
|
||||
@@ -36,6 +31,9 @@ module Spree
|
||||
# - shows products in order cycle distribution
|
||||
# - doesn't show products not in order cycle distribution
|
||||
|
||||
# Other things to test:
|
||||
# - no duplicates
|
||||
|
||||
describe "in_supplier" do
|
||||
it "shows products in supplier" do
|
||||
s = create(:supplier_enterprise)
|
||||
@@ -51,6 +49,37 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
describe "in_distributor" do
|
||||
it "shows products in product distribution" do
|
||||
d = create(:distributor_enterprise)
|
||||
p = create(:product, :distributors => [d])
|
||||
Product.in_distributor(d).should == [p]
|
||||
end
|
||||
|
||||
it "doesn't show products in another product distribution" do
|
||||
d1 = create(:distributor_enterprise)
|
||||
d2 = create(:distributor_enterprise)
|
||||
p = create(:product, :distributors => [d1])
|
||||
Product.in_distributor(d2).should be_empty
|
||||
end
|
||||
|
||||
it "shows products in order cycle distribution" do
|
||||
s = create(:supplier_enterprise)
|
||||
d = create(:distributor_enterprise)
|
||||
p = create(:product)
|
||||
create(:simple_order_cycle, :suppliers => [s], :distributors => [d], :variants => [p.master])
|
||||
Product.in_distributor(d).should == [p]
|
||||
end
|
||||
|
||||
it "doesn't show products in another order cycle distribution" do
|
||||
s = create(:supplier_enterprise)
|
||||
d1 = create(:distributor_enterprise)
|
||||
d2 = create(:distributor_enterprise)
|
||||
p = create(:product)
|
||||
create(:simple_order_cycle, :suppliers => [s], :distributors => [d1], :variants => [p.master])
|
||||
Product.in_distributor(d2).should be_empty
|
||||
end
|
||||
end
|
||||
|
||||
# describe "in_order_cycle_distributor" do
|
||||
# it "finds products listed by master" do
|
||||
|
||||
Reference in New Issue
Block a user