Commit a0127b6b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '254184_hide_create_issue_url_if_issues_are_disabled' into 'master'

Set `create_issue_url` as nil if issues are disabled

See merge request gitlab-org/gitlab!42993
parents 149846e1 09eb6775
......@@ -10,7 +10,7 @@ module VulnerabilitiesHelper
result = {
timestamp: Time.now.to_i,
create_issue_url: create_issue_project_security_vulnerability_path(vulnerability.project, vulnerability),
create_issue_url: create_issue_url_for(vulnerability),
has_mr: !!vulnerability.finding.merge_request_feedback.try(:merge_request_iid),
create_mr_url: create_vulnerability_feedback_merge_request_path(vulnerability.finding.project),
discussions_url: discussions_project_security_vulnerability_path(vulnerability.project, vulnerability),
......@@ -26,6 +26,12 @@ module VulnerabilitiesHelper
result.merge(vulnerability_data(vulnerability), vulnerability_finding_data(vulnerability))
end
def create_issue_url_for(vulnerability)
return unless vulnerability.project.issues_enabled?
create_issue_project_security_vulnerability_path(vulnerability.project, vulnerability)
end
def vulnerability_pipeline_data(pipeline)
return unless pipeline
......
......@@ -69,6 +69,16 @@ RSpec.describe VulnerabilitiesHelper do
can_modify_related_issues: false
)
end
context 'when the issues are disabled for the project' do
before do
allow(project).to receive(:issues_enabled?).and_return(false)
end
it 'has `create_issue_url` set as nil' do
expect(subject).to include(create_issue_url: nil)
end
end
end
describe '#vulnerability_details' do
......
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