diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-13 13:57:18 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-13 13:57:18 +0100 |
commit | a9ec4ec07e64d5f823c30d9bcc4c4bb1be7f2d75 (patch) | |
tree | bca595d7032bc68936991536a5363361663bd646 | |
parent | 5f590a71fd26b637501f8751bc6f9adff4d9c8db (diff) | |
download | gitlab-ce-a9ec4ec07e64d5f823c30d9bcc4c4bb1be7f2d75.tar.gz |
Make build retryable only if complete and executed
-rw-r--r-- | app/models/ci/build.rb | 3 | ||||
-rw-r--r-- | spec/models/build_spec.rb | 38 |
2 files changed, 32 insertions, 9 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 63a4a075f8e..89b0cae25ed 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -134,7 +134,8 @@ module Ci end def retryable? - project.builds_enabled? && commands.present? && complete? + project.builds_enabled? && commands.present? && + (success? || failed?) end def retried? diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index d4970e38f7c..2b678355ee5 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -900,20 +900,42 @@ describe Ci::Build, models: true do end describe '#retryable?' do - context 'when build is running' do - before do - build.run! + subject { build } + + context 'when build is retryable' do + context 'when build is successful' do + before do + build.success! + end + + it { is_expected.to be_retryable } end - it { expect(build).not_to be_retryable } + context 'when build is failed' do + before do + build.drop! + end + + it { is_expected.to be_retryable } + end end - context 'when build is finished' do - before do - build.success! + context 'when build is not retryable' do + context 'when build is running' do + before do + build.run! + end + + it { is_expected.not_to be_retryable } end - it { expect(build).to be_retryable } + context 'when build is skipped' do + before do + build.skip! + end + + it { is_expected.not_to be_retryable } + end end end |