Commit b8f67c5e authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not display ci build status if builds enabled but no `.gitlab-ci.yml`

Ref #3827
parent 2dafec91
...@@ -220,6 +220,16 @@ module Ci ...@@ -220,6 +220,16 @@ module Ci
update!(committed_at: DateTime.now) update!(committed_at: DateTime.now)
end 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 private
def save_yaml_error(error) def save_yaml_error(error)
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
- @commit.parents.each do |parent| - @commit.parents.each do |parent|
= link_to parent.short_id, namespace_project_commit_path(@project.namespace, @project, parent), class: "monospace" = 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 .pull-right
= link_to ci_status_path(@ci_commit), class: "ci-status ci-#{@ci_commit.status}" do = link_to ci_status_path(@ci_commit), class: "ci-status ci-#{@ci_commit.status}" do
= ci_status_icon(@ci_commit) = ci_status_icon(@ci_commit)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
- cache_key.push(ci_commit.status) if ci_commit - cache_key.push(ci_commit.status) if ci_commit
= cache(cache_key) do = cache(cache_key) do
%li.commit.js-toggle-container %li.commit.js-toggle-container{ id: "commit-#{commit.short_id}" }
.commit-row-title .commit-row-title
%strong.str-truncated %strong.str-truncated
= link_to_gfm commit.title, namespace_project_commit_path(project.namespace, project, commit.id), class: "commit-row-message" = link_to_gfm commit.title, namespace_project_commit_path(project.namespace, project, commit.id), class: "commit-row-message"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
%a.text-expander.js-toggle-button ... %a.text-expander.js-toggle-button ...
.pull-right .pull-right
- if ci_commit - if ci_commit && ci_commit.show_build_status?
= render_ci_status(ci_commit) = render_ci_status(ci_commit)
   
= clipboard_button(clipboard_text: commit.id) = clipboard_button(clipboard_text: commit.id)
......
...@@ -19,7 +19,36 @@ describe 'Commits' do ...@@ -19,7 +19,36 @@ describe 'Commits' do
let!(:build) { FactoryGirl.create :ci_build, commit: commit } 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 before do
visit ci_status_path(commit) visit ci_status_path(commit)
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