diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-17 12:38:21 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-17 12:38:21 +0200 |
commit | 9bb7f19d15ac5412a1d4c816f4b3eebcb3c5a840 (patch) | |
tree | bd17b361c3b746ee887b33ec4dc2377974993605 /spec/models | |
parent | c1918fb10b333593837c15bf4a6fa161ca502b4b (diff) | |
download | gitlab-ce-9bb7f19d15ac5412a1d4c816f4b3eebcb3c5a840.tar.gz |
Make it possible to count a number of job retries
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/ci/build_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 154b6759f46..615d1e09a11 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -802,6 +802,47 @@ describe Ci::Build, :models do end end + describe 'build auto retry feature' do + describe '#retries_count' do + subject { create(:ci_build, name: 'test', pipeline: pipeline) } + + context 'when build has been retried several times' do + before do + create(:ci_build, :retried, name: 'test', pipeline: pipeline) + create(:ci_build, :retried, name: 'test', pipeline: pipeline) + end + + it 'reports a correct retry count value' do + expect(subject.retries_count).to eq 2 + end + end + + context 'when build has not been retried' do + it 'returns zero' do + expect(subject.retries_count).to eq 0 + end + end + end + + describe '#retries_max' do + context 'when max retries value is defined' do + subject { create(:ci_build, options: { retry: 3 }) } + + it 'returns a number of configured max retries' do + expect(subject.retries_max).to eq 3 + end + end + + context 'when max retries value is not defined' do + subject { create(:ci_build) } + + it 'returns zero' do + expect(subject.retries_max).to eq 0 + end + end + end + end + describe '#keep_artifacts!' do let(:build) { create(:ci_build, artifacts_expire_at: Time.now + 7.days) } |