mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Fix product import entry validation
This commit is contained in:
@@ -287,9 +287,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def inventory_validation(entry)
|
||||
products = Spree::Product.where(supplier_id: entry.producer_id,
|
||||
name: entry.name,
|
||||
deleted_at: nil)
|
||||
products = Spree::Product.in_supplier(entry.producer_id).where(name: entry.name)
|
||||
|
||||
if products.empty?
|
||||
mark_as_invalid(entry, attribute: 'name',
|
||||
|
||||
@@ -63,12 +63,12 @@ RSpec.describe ProductImport::EntryValidator do
|
||||
let(:potatoes) {
|
||||
create(
|
||||
:simple_product,
|
||||
supplier: enterprise,
|
||||
on_hand: '100',
|
||||
name: 'Potatoes',
|
||||
unit_value: 1000,
|
||||
variant_unit_scale: 1000,
|
||||
variant_unit: 'weight'
|
||||
variant_unit: 'weight',
|
||||
variants: [create(:variant, supplier: enterprise)]
|
||||
)
|
||||
}
|
||||
|
||||
@@ -119,24 +119,24 @@ RSpec.describe ProductImport::EntryValidator do
|
||||
let!(:product_g) {
|
||||
create(
|
||||
:simple_product,
|
||||
supplier: enterprise,
|
||||
on_hand: '100',
|
||||
name: 'Tomato',
|
||||
unit_value: 500,
|
||||
variant_unit_scale: 1,
|
||||
variant_unit: 'weight'
|
||||
variant_unit: 'weight',
|
||||
variants: [create(:variant, supplier: enterprise, unit_value: 500)]
|
||||
)
|
||||
}
|
||||
|
||||
let!(:product_kg) {
|
||||
create(
|
||||
:simple_product,
|
||||
supplier: enterprise,
|
||||
on_hand: '100',
|
||||
name: 'Potatoes',
|
||||
unit_value: 1000,
|
||||
variant_unit_scale: 1000,
|
||||
variant_unit: 'weight'
|
||||
variant_unit: 'weight',
|
||||
variants: [create(:variant, supplier: enterprise, unit_value: 1000)]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user