mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Adjustments for new Settings and ResetAbsent classes
This commit is contained in:
@@ -4,10 +4,10 @@ module ProductImport
|
||||
@excluded_items_ids = excluded_items_ids
|
||||
end
|
||||
|
||||
def reset(supplier_ids)
|
||||
@supplier_ids = supplier_ids
|
||||
def reset(enterprise_ids)
|
||||
@enterprise_ids = enterprise_ids
|
||||
|
||||
if supplier_ids.present?
|
||||
if enterprise_ids.present?
|
||||
relation.update_all(count_on_hand: 0)
|
||||
else
|
||||
0
|
||||
@@ -16,10 +16,10 @@ module ProductImport
|
||||
|
||||
private
|
||||
|
||||
attr_reader :excluded_items_ids, :supplier_ids
|
||||
attr_reader :excluded_items_ids, :enterprise_ids
|
||||
|
||||
def relation
|
||||
relation = VariantOverride.where(hub_id: supplier_ids)
|
||||
relation = VariantOverride.where(hub_id: enterprise_ids)
|
||||
return relation if excluded_items_ids.blank?
|
||||
|
||||
relation.where('id NOT IN (?)', excluded_items_ids)
|
||||
|
||||
@@ -4,10 +4,10 @@ module ProductImport
|
||||
@excluded_items_ids = excluded_items_ids
|
||||
end
|
||||
|
||||
def reset(supplier_ids)
|
||||
@supplier_ids = supplier_ids
|
||||
def reset(enterprise_ids)
|
||||
@enterprise_ids = enterprise_ids
|
||||
|
||||
if supplier_ids.present?
|
||||
if enterprise_ids.present?
|
||||
relation.update_all(count_on_hand: 0)
|
||||
else
|
||||
0
|
||||
@@ -16,13 +16,13 @@ module ProductImport
|
||||
|
||||
private
|
||||
|
||||
attr_reader :excluded_items_ids, :supplier_ids
|
||||
attr_reader :excluded_items_ids, :enterprise_ids
|
||||
|
||||
def relation
|
||||
relation = Spree::Variant
|
||||
.joins(:product)
|
||||
.where(
|
||||
spree_products: { supplier_id: supplier_ids },
|
||||
spree_products: { supplier_id: enterprise_ids },
|
||||
spree_variants: { is_master: false, deleted_at: nil }
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ describe ProductImport::Settings do
|
||||
|
||||
context 'when there are settings' do
|
||||
let(:entry) do
|
||||
instance_double(ProductImport::SpreadsheetEntry, supplier_id: 1)
|
||||
instance_double(ProductImport::SpreadsheetEntry, enterprise_id: 1)
|
||||
end
|
||||
let(:import_settings) { { settings: {} } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user