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 ...@@ -38,6 +38,10 @@ module EE
project_security_vulnerability_path(entity.project, entity, *args) project_security_vulnerability_path(entity.project, entity, *args)
end end
def vulnerability_url(vulnerability)
::Gitlab::UrlBuilder.build(vulnerability)
end
def project_vulnerability_path(project, vulnerability, *args) def project_vulnerability_path(project, vulnerability, *args)
project_security_vulnerability_path(project, vulnerability, *args) project_security_vulnerability_path(project, vulnerability, *args)
end 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") %>: ### <%= _("Description") %>:
<%= vulnerability.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 ...@@ -142,4 +142,14 @@ RSpec.describe EE::GitlabRoutingHelper do
end end
end 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 end
...@@ -97,6 +97,8 @@ RSpec.describe Issues::CreateFromVulnerabilityService, '#execute' do ...@@ -97,6 +97,8 @@ RSpec.describe Issues::CreateFromVulnerabilityService, '#execute' do
let(:expected_title) { "Investigate vulnerability: #{vulnerability.title}" } let(:expected_title) { "Investigate vulnerability: #{vulnerability.title}" }
let(:expected_description) do let(:expected_description) do
<<~DESC.chomp <<~DESC.chomp
Issue created from vulnerability <a href="http://localhost/#{group.name}/#{project.name}/-/security/vulnerabilities/#{vulnerability.id}">#{vulnerability.id}</a>
### Description: ### Description:
Description of #{vulnerability.title} Description of #{vulnerability.title}
......
...@@ -14120,6 +14120,9 @@ msgstr "" ...@@ -14120,6 +14120,9 @@ msgstr ""
msgid "Issue cannot be found." msgid "Issue cannot be found."
msgstr "" msgstr ""
msgid "Issue created from vulnerability %{vulnerability_link}"
msgstr ""
msgid "Issue events" msgid "Issue events"
msgstr "" 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