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:
luisramos0
2019-02-01 08:32:45 +00:00
parent 4b9be6f1a8
commit 80af7c770b
2 changed files with 4 additions and 10 deletions

View File

@@ -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

View File

@@ -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