Commit 8bb2defe authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'add_link_to_vulnerability_from_issue' into 'master'

Add link to vulnerability from created issue

See merge request gitlab-org/gitlab!43046
parents 7b15069d ab141ade
......@@ -38,6 +38,10 @@ module EE
project_security_vulnerability_path(entity.project, entity, *args)
end
def vulnerability_url(vulnerability)
::Gitlab::UrlBuilder.build(vulnerability)
end
def project_vulnerability_path(project, vulnerability, *args)
project_security_vulnerability_path(project, vulnerability, *args)
end
......
<% if vulnerability.is_a? Vulnerability %>
<%= _("Issue created from vulnerability %{vulnerability_link}".html_safe) % { vulnerability_link: link_to(vulnerability.id, vulnerability_url(vulnerability)) } %>
<% end %>
### <%= _("Description") %>:
<%= vulnerability.description %>
......
---
title: Add link to vulnerability from created issue
merge_request: 43046
author:
type: changed
......@@ -142,4 +142,14 @@ RSpec.describe EE::GitlabRoutingHelper do
end
end
end
describe '#vulnerability_url' do
let_it_be(:vulnerability) { create(:vulnerability) }
subject { vulnerability_url(vulnerability) }
it 'returns the full url of the vulnerability' do
expect(subject).to eq "http://localhost/#{vulnerability.project.namespace.path}/#{vulnerability.project.name}/-/security/vulnerabilities/#{vulnerability.id}"
end
end
end
......@@ -97,6 +97,8 @@ RSpec.describe Issues::CreateFromVulnerabilityService, '#execute' do
let(:expected_title) { "Investigate vulnerability: #{vulnerability.title}" }
let(:expected_description) do
<<~DESC.chomp
Issue created from vulnerability <a href="http://localhost/#{group.name}/#{project.name}/-/security/vulnerabilities/#{vulnerability.id}">#{vulnerability.id}</a>
### Description:
Description of #{vulnerability.title}
......
......@@ -14120,6 +14120,9 @@ msgstr ""
msgid "Issue cannot be found."
msgstr ""
msgid "Issue created from vulnerability %{vulnerability_link}"
msgstr ""
msgid "Issue events"
msgstr ""
......
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