From 249a3c4e182eed65e7158251a34c03a1ced5fcfe Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sat, 17 Aug 2019 19:19:46 +0100 Subject: [PATCH] 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 --- app/models/spree/product_set.rb | 1 + spec/models/spree/product_set_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/spree/product_set.rb b/app/models/spree/product_set.rb index f96a1afc2b..4b78be91a0 100644 --- a/app/models/spree/product_set.rb +++ b/app/models/spree/product_set.rb @@ -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 diff --git a/spec/models/spree/product_set_spec.rb b/spec/models/spree/product_set_spec.rb index 397bcfe01a..3cf3a88975 100644 --- a/spec/models/spree/product_set_spec.rb +++ b/spec/models/spree/product_set_spec.rb @@ -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