Commit 0ea7f32a authored by Lin Jen-Shin's avatar Lin Jen-Shin

Make cancelled pipelines being able to retry

Closes #23326
parent cb8654e8
...@@ -152,7 +152,7 @@ module Ci ...@@ -152,7 +152,7 @@ module Ci
def retryable? def retryable?
builds.latest.any? do |build| builds.latest.any? do |build|
build.failed? && build.retryable? (build.failed? || build.canceled?) && build.retryable?
end end
end end
......
...@@ -88,24 +88,38 @@ describe Ci::Pipeline, models: true do ...@@ -88,24 +88,38 @@ describe Ci::Pipeline, models: true do
context 'no failed builds' do context 'no failed builds' do
before do before do
FactoryGirl.create :ci_build, name: "rspec", pipeline: pipeline, status: 'success' create_build('rspec', 'success')
end end
it 'be not retryable' do it 'is not retryable' do
is_expected.to be_falsey is_expected.to be_falsey
end end
context 'one canceled job' do
before do
create_build('rubocop', 'canceled')
end
it 'is retryable' do
is_expected.to be_truthy
end
end
end end
context 'with failed builds' do context 'with failed builds' do
before do before do
FactoryGirl.create :ci_build, name: "rspec", pipeline: pipeline, status: 'running' create_build('rspec', 'running')
FactoryGirl.create :ci_build, name: "rubocop", pipeline: pipeline, status: 'failed' create_build('rubocop', 'failed')
end end
it 'be retryable' do it 'is retryable' do
is_expected.to be_truthy is_expected.to be_truthy
end end
end end
def create_build(name, status)
create(:ci_build, name: name, status: status, pipeline: pipeline)
end
end end
describe '#stages' do describe '#stages' do
......
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