mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user