Commit 0876f8ee authored by Jiaan Louw's avatar Jiaan Louw Committed by Kushal Pandya

Add pipeline status to compliance dashboard

This adds a pipeline status icon to the merge requests
shown in the compliance dashboard.
parent 0aff7751
...@@ -46,9 +46,7 @@ ...@@ -46,9 +46,7 @@
%li.issuable-status.d-none.d-sm-inline-block %li.issuable-status.d-none.d-sm-inline-block
= icon('ban') = icon('ban')
= _('CLOSED') = _('CLOSED')
- if can?(current_user, :read_pipeline, merge_request.head_pipeline) = render 'shared/merge_request_pipeline_status', merge_request: merge_request
%li.issuable-pipeline-status.d-none.d-sm-flex
= render 'ci/status/icon', status: merge_request.head_pipeline.detailed_status(current_user), option_css_classes: 'd-flex'
- if merge_request.open? && merge_request.broken? - if merge_request.open? && merge_request.broken?
%li.issuable-pipeline-broken.d-none.d-sm-flex %li.issuable-pipeline-broken.d-none.d-sm-flex
= link_to merge_request_path(merge_request), class: "has-tooltip", title: _('Cannot be merged automatically') do = link_to merge_request_path(merge_request), class: "has-tooltip", title: _('Cannot be merged automatically') do
......
- if can?(current_user, :read_pipeline, merge_request.head_pipeline)
%li.issuable-pipeline-status.d-none.d-sm-flex
= render 'ci/status/icon', status: merge_request.head_pipeline.detailed_status(current_user), option_css_classes: 'd-flex'
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
.issuable-meta .issuable-meta
%ul.controls %ul.controls
= render 'shared/merge_request_pipeline_status', merge_request: merge_request
- if merge_request.approved_by_users.any? - if merge_request.approved_by_users.any?
= render 'approvers', project: merge_request.project, merge_request: merge_request = render 'approvers', project: merge_request.project, merge_request: merge_request
- else - else
......
---
title: Add pipeline statuses to Compliance Dashboard
merge_request: 28001
author:
type: added
...@@ -23,6 +23,7 @@ describe 'groups/security/compliance_dashboards/show.html.haml' do ...@@ -23,6 +23,7 @@ describe 'groups/security/compliance_dashboards/show.html.haml' do
context 'when there are merge requests' do context 'when there are merge requests' do
let(:merge_request) { create(:merge_request, source_project: project, state: :merged) } let(:merge_request) { create(:merge_request, source_project: project, state: :merged) }
let(:current_user) { user }
before do before do
merge_request.metrics.update!(merged_at: 10.minutes.ago) merge_request.metrics.update!(merged_at: 10.minutes.ago)
...@@ -42,6 +43,45 @@ describe 'groups/security/compliance_dashboards/show.html.haml' do ...@@ -42,6 +43,45 @@ describe 'groups/security/compliance_dashboards/show.html.haml' do
expect(rendered).to have_css('time', class: 'js-timeago') expect(rendered).to have_css('time', class: 'js-timeago')
end end
context 'with no pipeline' do
it 'renders no pipeline status icon' do
render
expect(rendered).not_to have_css('.ci-status-link')
end
end
context 'with a pipeline' do
context 'and the user is logged in' do
before do
sign_in(current_user)
end
::Ci::Pipeline.bridgeable_statuses.each do |status|
context "and the status is #{status}" do
let!(:pipeline) { create(:ci_empty_pipeline, status: status, project: project, head_pipeline_of: merge_request) }
it "renders the pipeline status icon for #{status}" do
render
expect(rendered).to have_css(".ci-status-link.ci-status-icon-#{status}")
end
end
end
end
context 'and the user is not logged in' do
let(:status) { ::Ci::Pipeline.bridgeable_statuses.first }
let!(:pipeline) { create(:ci_empty_pipeline, status: status, project: project, head_pipeline_of: merge_request) }
it "does not render a pipeline status icon" do
render
expect(rendered).not_to have_css(".ci-status-link.ci-status-icon")
end
end
end
context 'with no approvers' do context 'with no approvers' do
it 'renders the message "No approvers"' do it 'renders the message "No approvers"' do
render render
......
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