mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Spree::Product remove in_supplier_or_distributor scope
It is not used anywhere
This commit is contained in:
@@ -140,18 +140,6 @@ module Spree
|
||||
distinct
|
||||
}
|
||||
|
||||
# Products supplied by a given enterprise or distributed via that enterprise through an OC
|
||||
scope :in_supplier_or_distributor, lambda { |enterprise|
|
||||
enterprise = enterprise.respond_to?(:id) ? enterprise.id : enterprise.to_i
|
||||
|
||||
with_order_cycles_outer.
|
||||
in_supplier(enterprise).
|
||||
or(
|
||||
where(o_exchanges: { incoming: false, receiver_id: enterprise })
|
||||
).
|
||||
select('distinct spree_products.*')
|
||||
}
|
||||
|
||||
# Products distributed by the given order cycle
|
||||
scope :in_order_cycle, lambda { |order_cycle|
|
||||
with_order_cycles_inner.
|
||||
|
||||
@@ -471,43 +471,6 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
describe "in_supplier_or_distributor" do
|
||||
it "shows products in supplier" do
|
||||
s1 = create(:supplier_enterprise)
|
||||
p1 = create(:product, supplier_id: s1.id)
|
||||
create(:variant, product: p1, supplier: s1)
|
||||
s2 = create(:supplier_enterprise)
|
||||
p2 = create(:product, supplier_id: s2.id)
|
||||
create(:variant, product: p2, supplier: s2)
|
||||
|
||||
expect(Product.in_supplier_or_distributor(s1)).to eq([p1])
|
||||
end
|
||||
|
||||
it "shows products in order cycle distribution" do
|
||||
s = create(:supplier_enterprise)
|
||||
d1 = create(:distributor_enterprise)
|
||||
d2 = create(:distributor_enterprise)
|
||||
p1 = create(:product)
|
||||
p2 = create(:product)
|
||||
create(:simple_order_cycle, suppliers: [s], distributors: [d1],
|
||||
variants: [p1.variants.first])
|
||||
create(:simple_order_cycle, suppliers: [s], distributors: [d2],
|
||||
variants: [p2.variants.first])
|
||||
expect(Product.in_supplier_or_distributor(d1)).to eq([p1])
|
||||
end
|
||||
|
||||
it "shows products in all three without duplicates" do
|
||||
s = create(:supplier_enterprise)
|
||||
d = create(:distributor_enterprise)
|
||||
p = create(:product)
|
||||
create(:variant, product: p, supplier: s)
|
||||
|
||||
create(:simple_order_cycle, suppliers: [s], distributors: [d],
|
||||
variants: [p.variants.first])
|
||||
[s, d].each { |e| expect(Product.in_supplier_or_distributor(e)).to eq([p]) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "in_order_cycle" do
|
||||
it "shows products in order cycle distribution" do
|
||||
s = create(:supplier_enterprise)
|
||||
|
||||
Reference in New Issue
Block a user