diff options
author | Luke Duncalfe <lduncalfe@eml.cc> | 2019-04-09 10:55:07 +1200 |
---|---|---|
committer | Luke Duncalfe <lduncalfe@eml.cc> | 2019-04-09 10:57:04 +1200 |
commit | b5bcf80c9a7470ac36bdbefcb8056beff67712ae (patch) | |
tree | 8bc00389e054d0aa68d659f9d117b8777f434c44 /spec/services/merge_requests | |
parent | 3c40c98e263328ceb11a008dbec108362e727dbc (diff) | |
download | gitlab-ce-b5bcf80c9a7470ac36bdbefcb8056beff67712ae.tar.gz |
Update service to handle unexpected exceptions43263-git-push-option-to-create-mr
This will ensure that now and in the future, PushOptionsHandlerService
will not cause the post_receive API endpoint from running other code if
something causes an unknown exception.
Diffstat (limited to 'spec/services/merge_requests')
-rw-r--r-- | spec/services/merge_requests/push_options_handler_service_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/services/merge_requests/push_options_handler_service_spec.rb b/spec/services/merge_requests/push_options_handler_service_spec.rb index af52feef24d..686b4b49f24 100644 --- a/spec/services/merge_requests/push_options_handler_service_spec.rb +++ b/spec/services/merge_requests/push_options_handler_service_spec.rb @@ -334,6 +334,32 @@ describe MergeRequests::PushOptionsHandlerService do end end + describe 'handling unexpected exceptions' do + let(:push_options) { { create: true } } + let(:changes) { new_branch_changes } + let(:exception) { StandardError.new('My standard error') } + + def run_service_with_exception + allow_any_instance_of( + MergeRequests::BuildService + ).to receive(:execute).and_raise(exception) + + service.execute + end + + it 'records an error' do + run_service_with_exception + + expect(service.errors).to eq(['An unknown error occurred']) + end + + it 'writes to Gitlab::AppLogger' do + expect(Gitlab::AppLogger).to receive(:error).with(exception) + + run_service_with_exception + end + end + describe 'when target is not a valid branch name' do let(:push_options) { { create: true, target: 'my-branch' } } let(:changes) { new_branch_changes } |