Make product set raise error and inform the user something went wrong and keep bugsnag notification so we can get more information about what's going on

This commit is contained in:
luisramos0
2019-08-17 19:19:46 +01:00
parent 2b8ebba233
commit 249a3c4e18
2 changed files with 3 additions and 2 deletions

View File

@@ -101,6 +101,7 @@ class Spree::ProductSet < ModelSet
variant.on_hand = on_hand.to_i if on_hand.present?
rescue StandardError => error
notify_bugsnag(error, product, variant, variant_attributes)
raise error
end
end

View File

@@ -116,11 +116,11 @@ describe Spree::ProductSet do
attributes_for(:variant).merge(unit_value: nil, on_hand: 1, sku: '321')
end
it 'does not create variant and notifies bugsnag without raising exception' do
it 'does not create variant and notifies bugsnag still raising the exception' do
expect(Bugsnag).to receive(:notify)
number_of_variants = Spree::Variant.all.size
expect { product_set.save }
.not_to raise_error(StandardError)
.to raise_error(StandardError)
expect(Spree::Variant.all.size).to eq number_of_variants
expect(Spree::Variant.last.sku).not_to eq('321')
end