mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #7015 from andrewpbrett/shopfront-producers
Only show primary producers on shopfront list of producers (fix #4218)
This commit is contained in:
@@ -250,7 +250,7 @@ class Enterprise < ActiveRecord::Base
|
||||
|
||||
def plus_relatives_and_oc_producers(order_cycles)
|
||||
oc_producer_ids = Exchange.in_order_cycle(order_cycles).incoming.pluck :sender_id
|
||||
Enterprise.relatives_of_one_union_others(id, oc_producer_ids | [id])
|
||||
Enterprise.is_primary_producer.relatives_of_one_union_others(id, oc_producer_ids | [id])
|
||||
end
|
||||
|
||||
def relatives_including_self
|
||||
|
||||
@@ -599,4 +599,19 @@ describe Enterprise do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#plus_relatives_and_oc_producers" do
|
||||
it "does not find non-produders " do
|
||||
supplier = create(:supplier_enterprise)
|
||||
distributor = create(:distributor_enterprise, is_primary_producer: false)
|
||||
product = create(:product)
|
||||
order_cycle = create(
|
||||
:simple_order_cycle,
|
||||
suppliers: [supplier],
|
||||
distributors: [distributor],
|
||||
variants: [product.master]
|
||||
)
|
||||
expect(distributor.plus_relatives_and_oc_producers(order_cycle)).to eq([supplier])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user