diff --git a/app/models/product_import/products_reset_strategy.rb b/app/models/product_import/products_reset_strategy.rb index b05bfa6906..0dc005af82 100644 --- a/app/models/product_import/products_reset_strategy.rb +++ b/app/models/product_import/products_reset_strategy.rb @@ -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 diff --git a/spec/models/product_import/products_reset_strategy_spec.rb b/spec/models/product_import/products_reset_strategy_spec.rb index 1b7738262b..c3aa64a00b 100644 --- a/spec/models/product_import/products_reset_strategy_spec.rb +++ b/spec/models/product_import/products_reset_strategy_spec.rb @@ -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