diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 18:07:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 18:07:22 +0300 |
commit | d41edc2e93480db35e48ad770ebe95075fbca871 (patch) | |
tree | 09d4f5cd1575babf508c73a2653f68b35cd1e936 /spec/services | |
parent | b17a559378235d37f5168d8d18818043cdaaf90b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-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 |