diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2019-04-07 10:51:36 +0300 |
---|---|---|
committer | Michael Kozono <mkozono@gmail.com> | 2019-04-07 10:51:36 +0300 |
commit | bbb17ea1ea619664b362a9c984da45b940c412a2 (patch) | |
tree | 617df6d7bd4186c7f1eec0374e975375323d20b9 /spec/services/error_tracking/list_projects_service_spec.rb | |
parent | ae91b3219aa0b5de20e3452126384341acef75c6 (diff) |
Handle possible HTTP exception for Sentry client
Prior this commit exceptions raised during a HTTP request
weren't caught by the Sentry client and were passed to the user.
In addition the Sentry client tried to catch a non-existent error
`Sentry::Client::SentryError`.
Now, the Sentry client catches all possible errors coming from
a HTTP request.
Diffstat (limited to 'spec/services/error_tracking/list_projects_service_spec.rb')
-rw-r--r-- | spec/services/error_tracking/list_projects_service_spec.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/spec/services/error_tracking/list_projects_service_spec.rb b/spec/services/error_tracking/list_projects_service_spec.rb index a92d3376f7b..730fccc599e 100644 --- a/spec/services/error_tracking/list_projects_service_spec.rb +++ b/spec/services/error_tracking/list_projects_service_spec.rb @@ -51,14 +51,28 @@ describe ErrorTracking::ListProjectsService do end context 'sentry client raises exception' do - before do - expect(error_tracking_setting).to receive(:list_sentry_projects) - .and_raise(Sentry::Client::Error, 'Sentry response status code: 500') + context 'Sentry::Client::Error' do + before do + expect(error_tracking_setting).to receive(:list_sentry_projects) + .and_raise(Sentry::Client::Error, 'Sentry response status code: 500') + end + + it 'returns error response' do + expect(result[:message]).to eq('Sentry response status code: 500') + expect(result[:http_status]).to eq(:bad_request) + end end - it 'returns error response' do - expect(result[:message]).to eq('Sentry response status code: 500') - expect(result[:http_status]).to eq(:bad_request) + context 'Sentry::Client::MissingKeysError' do + before do + expect(error_tracking_setting).to receive(:list_sentry_projects) + .and_raise(Sentry::Client::MissingKeysError, 'Sentry API response is missing keys. key not found: "id"') + end + + it 'returns error response' do + expect(result[:message]).to eq('Sentry API response is missing keys. key not found: "id"') + expect(result[:http_status]).to eq(:internal_server_error) + end end end |