Commit f9c5f18d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve method that tells if build is retryable

This method now should return false if build is not completed. If build
is running then it is not retryable, therefore `Ci::Build#retryable?`
returned wrong value. This commit changes this behavior
parent 94cec500
......@@ -90,7 +90,7 @@ module Ci
end
def retryable?
project.builds_enabled? && commands.present?
project.builds_enabled? && commands.present? && complete?
end
def retried?
......
......@@ -40,7 +40,7 @@
.block{ class: ("block-first" if !@build.coverage && !(can?(current_user, :read_build, @project) && (@build.artifacts? || @build.artifacts_expired?))) }
.title
Build details
- if @build.retryable? && !@build.active?
- if @build.retryable?
= link_to "Retry", retry_namespace_project_build_path(@project.namespace, @project, @build), class: 'pull-right', method: :post
- if @build.merge_request
%p.build-detail-row
......
......@@ -669,4 +669,22 @@ describe Ci::Build, models: true do
expect(build.commit).to eq project.commit
end
end
describe '#retryable?' do
context 'when build is running' do
before { build.run! }
it 'should return false' do
expect(build.retryable?).to be false
end
end
context 'when build is finished' do
before { build.success! }
it 'should return true' do
expect(build.retryable?).to be true
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