Commit a9ec4ec0 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make build retryable only if complete and executed

parent 5f590a71
...@@ -134,7 +134,8 @@ module Ci ...@@ -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?
......
...@@ -900,20 +900,42 @@ describe Ci::Build, models: true do ...@@ -900,20 +900,42 @@ describe Ci::Build, models: true do
end end
describe '#retryable?' do describe '#retryable?' do
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
context 'when build is failed' do
before do
build.drop!
end
it { is_expected.to be_retryable }
end
end
context 'when build is not retryable' do
context 'when build is running' do context 'when build is running' do
before do before do
build.run! build.run!
end end
it { expect(build).not_to be_retryable } it { is_expected.not_to be_retryable }
end end
context 'when build is finished' do context 'when build is skipped' do
before do before do
build.success! build.skip!
end end
it { expect(build).to be_retryable } it { is_expected.not_to be_retryable }
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment