Do not display ci build status if builds enabled but no .gitlab-ci.yml
Ref #3827
This commit is contained in:
parent
2dafec91dd
commit
b8f67c5e47
4 changed files with 43 additions and 4 deletions
|
@ -220,6 +220,16 @@ module Ci
|
|||
update!(committed_at: DateTime.now)
|
||||
end
|
||||
|
||||
##
|
||||
# This method checks if build status should be displayed.
|
||||
#
|
||||
# Build status should be available only if builds are enabled
|
||||
# on project level and `.gitlab-ci.yml` file is present.
|
||||
#
|
||||
def show_build_status?
|
||||
gl_project.builds_enabled? && ci_yaml_file
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def save_yaml_error(error)
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
- @commit.parents.each do |parent|
|
||||
= link_to parent.short_id, namespace_project_commit_path(@project.namespace, @project, parent), class: "monospace"
|
||||
|
||||
- if @ci_commit
|
||||
- if @ci_commit && @ci_commit.show_build_status?
|
||||
.pull-right
|
||||
= link_to ci_status_path(@ci_commit), class: "ci-status ci-#{@ci_commit.status}" do
|
||||
= ci_status_icon(@ci_commit)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- cache_key.push(ci_commit.status) if ci_commit
|
||||
|
||||
= cache(cache_key) do
|
||||
%li.commit.js-toggle-container
|
||||
%li.commit.js-toggle-container{ id: "commit-#{commit.short_id}" }
|
||||
.commit-row-title
|
||||
%strong.str-truncated
|
||||
= link_to_gfm commit.title, namespace_project_commit_path(project.namespace, project, commit.id), class: "commit-row-message"
|
||||
|
@ -17,7 +17,7 @@
|
|||
%a.text-expander.js-toggle-button ...
|
||||
|
||||
.pull-right
|
||||
- if ci_commit
|
||||
- if ci_commit && ci_commit.show_build_status?
|
||||
= render_ci_status(ci_commit)
|
||||
|
||||
= clipboard_button(clipboard_text: commit.id)
|
||||
|
|
|
@ -19,7 +19,36 @@ describe 'Commits' do
|
|||
|
||||
let!(:build) { FactoryGirl.create :ci_build, commit: commit }
|
||||
|
||||
describe 'GET /:project/commits/:sha/ci' do
|
||||
describe 'Project commits' do
|
||||
context 'builds enabled' do
|
||||
context '.gitlab-ci.yml found' do
|
||||
before do
|
||||
visit namespace_project_commits_path(project.namespace, project, :master)
|
||||
end
|
||||
|
||||
it 'should show build status' do
|
||||
page.within("//li[@id='commit-#{commit.short_sha}']") do
|
||||
expect(page).to have_css(".ci-status-link")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'no .gitlab-ci.yml found' do
|
||||
before do
|
||||
stub_ci_commit_yaml_file(nil)
|
||||
visit namespace_project_commits_path(project.namespace, project, :master)
|
||||
end
|
||||
|
||||
it 'should not show build status' do
|
||||
page.within("//li[@id='commit-#{commit.short_sha}']") do
|
||||
expect(page).to have_no_css(".ci-status-link")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Commit builds' do
|
||||
before do
|
||||
visit ci_status_path(commit)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue