diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-03-20 19:27:23 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-03-20 19:27:23 +0300 |
commit | a2d82d4c5522b6d3668481e2fcfc77b0830ce9b6 (patch) | |
tree | 1dbd697794019471ed95ce417bc64ec01e4c64f7 /spec | |
parent | 500132e026923cae2a8b769ff1824a00e45bb98c (diff) | |
parent | 9c9c0484f61d6c8198c060c78fcfc9458c16955f (diff) |
Merge branch 'fix-ci-job-auto-retry' into 'master'
Prevent auto-retry AccessDenied error from stopping transition to failed
See merge request gitlab-org/gitlab-ce!17862
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 9da3de7a828..30a352fd090 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2101,6 +2101,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 |