diff options
| author | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-19 14:17:46 +0100 |
|---|---|---|
| committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2018-03-20 16:49:33 +0100 |
| commit | a61761908fde2f032f00f07d0ccc479177db6d3f (patch) | |
| tree | a8f4f1463fc0a2f2efd373208c2f2f58eab67f6b /spec | |
| parent | ea5221aeb358ef6c349cfa09b9c6993bd7bd027d (diff) | |
| download | gitlab-ce-a61761908fde2f032f00f07d0ccc479177db6d3f.tar.gz | |
Prevent auto-retry AccessDenied error from stopping transition to failed
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/ci/build_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 01203ff44c8..820827d078a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2065,6 +2065,35 @@ describe Ci::Build do subject.drop! end + + context 'when retry service raises Gitlab::Access::AccessDeniedError exception' do + let(:retry_service) { Ci::RetryBuildService.new(subject.project, subject.user) } + + before do + allow_any_instance_of(Ci::RetryBuildService) + .to receive(:execute) + .with(subject) + .and_raise(Gitlab::Access::AccessDeniedError) + allow(Rails.logger).to receive(:error) + end + + it 'handles raised exception' do + expect { subject.drop! }.not_to raise_exception(Gitlab::Access::AccessDeniedError) + end + + it 'logs the error' do + subject.drop! + + expect(Rails.logger) + .to have_received(:error) + .with(a_string_matching("Unable to auto-retry job #{subject.id}")) + end + + it 'fails the job' do + subject.drop! + expect(subject.failed?).to be_truthy + end + end end context 'when build is not configured to be retried' do |
