mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove stockable_by from Product and Variant
It's not used anymore
This commit is contained in:
@@ -165,17 +165,6 @@ module Spree
|
||||
end
|
||||
}
|
||||
|
||||
scope :stockable_by, lambda { |enterprise|
|
||||
return where('1=0') if enterprise.blank?
|
||||
|
||||
permitted_producer_ids = EnterpriseRelationship.joins(:parent).permitting(enterprise.id)
|
||||
.with_permission(:add_to_order_cycle)
|
||||
.where(enterprises: { is_primary_producer: true })
|
||||
.pluck(:parent_id)
|
||||
|
||||
in_supplier([enterprise.id].union(permitted_producer_ids))
|
||||
}
|
||||
|
||||
scope :active, lambda { where(spree_products: { deleted_at: nil }) }
|
||||
|
||||
def self.group_by_products_id
|
||||
|
||||
@@ -143,17 +143,6 @@ module Spree
|
||||
.where("o_inventory_items.id IS NULL OR o_inventory_items.visible = (?)", true)
|
||||
}
|
||||
|
||||
scope :stockable_by, lambda { |enterprise|
|
||||
return where("1=0") if enterprise.blank?
|
||||
|
||||
permitted_producer_ids = EnterpriseRelationship.joins(:parent).permitting(enterprise.id)
|
||||
.with_permission(:add_to_order_cycle)
|
||||
.where(enterprises: { is_primary_producer: true })
|
||||
.pluck(:parent_id)
|
||||
|
||||
where(supplier: [enterprise.id].union(permitted_producer_ids))
|
||||
}
|
||||
|
||||
scope :with_properties, lambda { |property_ids|
|
||||
left_outer_joins(:supplier_properties).
|
||||
where(producer_properties: { property_id: property_ids })
|
||||
|
||||
@@ -579,32 +579,6 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
describe 'stockable_by' do
|
||||
let(:shop) { create(:distributor_enterprise) }
|
||||
let(:add_to_oc_producer) { create(:supplier_enterprise) }
|
||||
let(:other_producer) { create(:supplier_enterprise) }
|
||||
let(:p1) { create(:simple_product) }
|
||||
let(:p2) { create(:simple_product) }
|
||||
let(:p3) { create(:simple_product) }
|
||||
|
||||
before do
|
||||
create(:variant, product: p1, supplier: shop)
|
||||
create(:variant, product: p2, supplier: add_to_oc_producer)
|
||||
create(:variant, product: p3, supplier: other_producer)
|
||||
|
||||
create(:enterprise_relationship, parent: add_to_oc_producer, child: shop,
|
||||
permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: other_producer, child: shop,
|
||||
permissions_list: [:manage_products])
|
||||
end
|
||||
|
||||
it 'shows products produced by the enterprise and any producers granting P-OC' do
|
||||
stockable_products = Spree::Product.stockable_by(shop)
|
||||
expect(stockable_products).to include p1, p2
|
||||
expect(stockable_products).not_to include p3
|
||||
end
|
||||
end
|
||||
|
||||
describe "imported_on" do
|
||||
let!(:v1) { create(:variant, import_date: 1.day.ago) }
|
||||
let!(:v2) { create(:variant, import_date: 2.days.ago) }
|
||||
|
||||
@@ -448,30 +448,6 @@ RSpec.describe Spree::Variant do
|
||||
end
|
||||
end
|
||||
|
||||
describe '.stockable_by' do
|
||||
let(:shop) { create(:distributor_enterprise) }
|
||||
let(:add_to_oc_producer) { create(:supplier_enterprise) }
|
||||
let(:other_producer) { create(:supplier_enterprise) }
|
||||
let!(:v1) { create(:variant, product: create(:simple_product), supplier: shop ) }
|
||||
let!(:v2) {
|
||||
create(:variant, product: create(:simple_product), supplier: add_to_oc_producer )
|
||||
}
|
||||
let!(:v3) { create(:variant, product: create(:simple_product), supplier: other_producer ) }
|
||||
|
||||
before do
|
||||
create(:enterprise_relationship, parent: add_to_oc_producer, child: shop,
|
||||
permissions_list: [:add_to_order_cycle])
|
||||
create(:enterprise_relationship, parent: other_producer, child: shop,
|
||||
permissions_list: [:manage_products])
|
||||
end
|
||||
|
||||
it 'shows variants produced by the enterprise and any producers granting P-OC' do
|
||||
stockable_variants = Spree::Variant.stockable_by(shop)
|
||||
expect(stockable_variants).to include v1, v2
|
||||
expect(stockable_variants).not_to include v3
|
||||
end
|
||||
end
|
||||
|
||||
describe ".with_properties" do
|
||||
let!(:variant_without_wanted_property_on_supplier) {
|
||||
create(:variant, supplier: supplier_without_wanted_property)
|
||||
|
||||
Reference in New Issue
Block a user