diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/services/service_response_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) | |
download | gitlab-ce-15.8.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/services/service_response_spec.rb')
-rw-r--r-- | spec/services/service_response_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/services/service_response_spec.rb b/spec/services/service_response_spec.rb index 2d70979dd3a..58dd2fd4c5e 100644 --- a/spec/services/service_response_spec.rb +++ b/spec/services/service_response_spec.rb @@ -178,4 +178,40 @@ RSpec.describe ServiceResponse do end end end + + describe '#log_and_raise_exception' do + context 'when successful' do + let(:response) { described_class.success } + + it 'returns self' do + expect(response.log_and_raise_exception).to be response + end + end + + context 'when an error' do + let(:response) { described_class.error(message: 'bang') } + + it 'logs' do + expect(::Gitlab::ErrorTracking).to receive(:log_and_raise_exception) + .with(StandardError.new('bang'), {}) + + response.log_and_raise_exception + end + + it 'allows specification of error class' do + error = Class.new(StandardError) + expect(::Gitlab::ErrorTracking).to receive(:log_and_raise_exception) + .with(error.new('bang'), {}) + + response.log_and_raise_exception(as: error) + end + + it 'allows extra data for tracking' do + expect(::Gitlab::ErrorTracking).to receive(:log_and_raise_exception) + .with(StandardError.new('bang'), { foo: 1, bar: 2 }) + + response.log_and_raise_exception(foo: 1, bar: 2) + end + end + end end |