diff options
Diffstat (limited to 'spec/lib/gitlab/error_tracking_spec.rb')
-rw-r--r-- | spec/lib/gitlab/error_tracking_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/error_tracking_spec.rb b/spec/lib/gitlab/error_tracking_spec.rb index c9b2e21d934..7b2c5ca27cb 100644 --- a/spec/lib/gitlab/error_tracking_spec.rb +++ b/spec/lib/gitlab/error_tracking_spec.rb @@ -173,6 +173,20 @@ RSpec.describe Gitlab::ErrorTracking, feature_category: :shared do ) end.to raise_error(RuntimeError) end + + it 'processes the exception even it is called within a `restrict_within_concurrent_ruby` block' do + expect(Gitlab::ErrorTracking::Logger).to receive(:error).with(logger_payload) + + expect do + Gitlab::Utils.restrict_within_concurrent_ruby do + described_class.track_and_raise_exception( + exception, + issue_url: issue_url, + some_other_info: 'info' + ) + end + end.to raise_error(RuntimeError, /boom/) + end end describe '.log_and_raise_exception' do @@ -188,6 +202,16 @@ RSpec.describe Gitlab::ErrorTracking, feature_category: :shared do expect { log_and_raise_exception }.to raise_error(RuntimeError) end + it 'processes the exception even it is called within a `restrict_within_concurrent_ruby` block' do + expect(Gitlab::ErrorTracking::Logger).to receive(:error).with(logger_payload) + + expect do + Gitlab::Utils.restrict_within_concurrent_ruby do + log_and_raise_exception + end + end.to raise_error(RuntimeError) + end + context 'when extra details are provided' do let(:extra) { { test: 1, my_token: 'test' } } @@ -230,6 +254,14 @@ RSpec.describe Gitlab::ErrorTracking, feature_category: :shared do expect(Gitlab::ErrorTracking::Logger).to have_received(:error).with(logger_payload) end + it 'processes the exception even it is called within a `restrict_within_concurrent_ruby` block' do + Gitlab::Utils.restrict_within_concurrent_ruby do + track_exception + end + + expect(Gitlab::ErrorTracking::Logger).to have_received(:error).with(logger_payload) + end + context 'with tags' do let(:tags) { { 'mytag' => 2 } } |