Make build retryable only if complete and executed

This commit is contained in:
Grzegorz Bizon 2016-12-13 13:57:18 +01:00
parent 5f590a71fd
commit a9ec4ec07e
2 changed files with 32 additions and 9 deletions

View File

@ -134,7 +134,8 @@ module Ci
end end
def retryable? def retryable?
project.builds_enabled? && commands.present? && complete? project.builds_enabled? && commands.present? &&
(success? || failed?)
end end
def retried? def retried?

View File

@ -900,20 +900,42 @@ describe Ci::Build, models: true do
end end
describe '#retryable?' do describe '#retryable?' do
context 'when build is running' do subject { build }
before do
build.run! context 'when build is retryable' do
context 'when build is successful' do
before do
build.success!
end
it { is_expected.to be_retryable }
end 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 end
context 'when build is finished' do context 'when build is not retryable' do
before do context 'when build is running' do
build.success! before do
build.run!
end
it { is_expected.not_to be_retryable }
end 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
end end