Commit e478eb91 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '242263_add_pipeline_information_to_security_dashboard_payload' into 'master'

Add pipeline information to security dashboard setup

See merge request gitlab-org/gitlab!42990
parents ce8b3cbe 196c704c
...@@ -232,7 +232,7 @@ module EE ...@@ -232,7 +232,7 @@ module EE
not_enabled_scanners_help_path: help_page_path('user/application_security/index', anchor: 'quick-start'), not_enabled_scanners_help_path: help_page_path('user/application_security/index', anchor: 'quick-start'),
no_pipeline_run_scanners_help_path: new_project_pipeline_path(project), no_pipeline_run_scanners_help_path: new_project_pipeline_path(project),
security_dashboard_help_path: help_page_path('user/application_security/security_dashboard/index') security_dashboard_help_path: help_page_path('user/application_security/security_dashboard/index')
} }.merge!(security_dashboard_pipeline_data(project))
end end
end end
...@@ -328,5 +328,18 @@ module EE ...@@ -328,5 +328,18 @@ module EE
codeClose: '</code>'.html_safe codeClose: '</code>'.html_safe
} }
end end
def security_dashboard_pipeline_data(project)
pipeline = project.latest_pipeline_with_security_reports
return {} unless pipeline
{
pipeline: {
id: pipeline.id,
path: pipeline_path(pipeline),
created_at: pipeline.created_at.to_s(:iso8601)
}
}
end
end end
end end
...@@ -142,11 +142,7 @@ RSpec.describe ProjectsHelper do ...@@ -142,11 +142,7 @@ RSpec.describe ProjectsHelper do
end end
context 'project with vulnerabilities' do context 'project with vulnerabilities' do
before do let(:base_values) do
create(:vulnerability, project: project)
end
let(:expected_values) do
{ {
has_vulnerabilities: 'true', has_vulnerabilities: 'true',
project: { id: project.id, name: project.name }, project: { id: project.id, name: project.name },
...@@ -158,11 +154,41 @@ RSpec.describe ProjectsHelper do ...@@ -158,11 +154,41 @@ RSpec.describe ProjectsHelper do
dashboard_documentation: '/help/user/application_security/security_dashboard/index', dashboard_documentation: '/help/user/application_security/security_dashboard/index',
security_dashboard_help_path: '/help/user/application_security/security_dashboard/index', security_dashboard_help_path: '/help/user/application_security/security_dashboard/index',
not_enabled_scanners_help_path: help_page_path('user/application_security/index', anchor: 'quick-start'), not_enabled_scanners_help_path: help_page_path('user/application_security/index', anchor: 'quick-start'),
no_pipeline_run_scanners_help_path: new_project_pipeline_path(project) no_pipeline_run_scanners_help_path: "/#{project.full_path}/-/pipelines/new"
}
end
before do
create(:vulnerability, project: project)
end
context 'without pipeline' do
before do
allow(project).to receive(:latest_pipeline_with_security_reports).and_return(nil)
end
it { is_expected.to match(base_values) }
end
context 'with pipeline' do
let(:pipeline_created_at) { '1881-05-19T00:00:00Z' }
let(:pipeline) { build_stubbed(:ci_pipeline, project: project, created_at: pipeline_created_at) }
let(:pipeline_values) do
{
pipeline: {
id: pipeline.id,
path: "/#{project.full_path}/-/pipelines/#{pipeline.id}",
created_at: pipeline_created_at
}
} }
end end
it { is_expected.to match(expected_values) } before do
allow(project).to receive(:latest_pipeline_with_security_reports).and_return(pipeline)
end
it { is_expected.to match(base_values.merge!(pipeline_values)) }
end
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