mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Remove rescue from products_reset_strategy in product import: if setting count_on_hand fails the import will raise a RuntimeError
This commit is contained in:
@@ -38,13 +38,8 @@ module ProductImport
|
||||
end
|
||||
|
||||
def reset_variant_count_on_hand(variant)
|
||||
begin
|
||||
variant.count_on_hand = 0
|
||||
return true if variant.count_on_hand.zero?
|
||||
rescue StandardError => e
|
||||
Rails.logger.info "Could not reset variant count on hand: #{e.message}"
|
||||
end
|
||||
false
|
||||
variant.count_on_hand = 0
|
||||
variant.count_on_hand.zero?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -80,12 +80,11 @@ describe ProductImport::ProductsResetStrategy do
|
||||
|
||||
context 'and there is an unresetable variant' do
|
||||
before do
|
||||
variant.stock_items = [] # this makes variant.count_on_hand fail
|
||||
variant.stock_items = [] # this makes variant.count_on_hand raise an error
|
||||
end
|
||||
|
||||
it 'returns correct number of resetted variants' do
|
||||
updated_records_count = products_reset.reset(supplier_ids)
|
||||
expect(updated_records_count).to eq(0) # the variant is not updated
|
||||
expect { products_reset.reset(supplier_ids) }.to raise_error RuntimeError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user