Commit 2af1a22a authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch...

Merge branch '284473-issues-created-from-vulnerabilities-detail-page-missing-information' into 'master'

Populate issue description from vulnerability finding if needed

See merge request gitlab-org/gitlab!52592
parents b2c36097 f3e2dc43
......@@ -52,6 +52,10 @@ class VulnerabilityPresenter < Gitlab::View::Presenter::Delegated
)
end
def description
vulnerability.description || finding.description
end
private
def location_link_for(path)
......
---
title: Properly populate descriptions in an issue created from a vulnerability
merge_request: 52592
author:
type: fixed
......@@ -9,7 +9,7 @@ RSpec.describe VulnerabilityPresenter do
{ type: 'sast', status: 'success', start_time: 'placeholder', end_time: 'placeholder' }
end
let_it_be(:finding) { create(:vulnerabilities_finding, :with_secret_detection, pipelines: [pipeline], project: project) }
let_it_be(:finding) { create(:vulnerabilities_finding, :with_secret_detection, pipelines: [pipeline], project: project, description: 'Finding Description') }
let_it_be(:finding2) { create(:vulnerabilities_finding, :with_secret_detection, scan: sast_scan) }
subject { described_class.new(finding.vulnerability) }
......@@ -127,4 +127,26 @@ RSpec.describe VulnerabilityPresenter do
expect(jira_issue_description).to eq(expected_jira_issue_description)
end
end
describe '#description' do
let(:vulnerability) { finding.vulnerability }
context 'when the vulnerability description field is populated' do
it 'returns the description for the vulnerability' do
expect(subject.description).to eq(vulnerability.description)
end
end
context 'when the vulnerability description field is empty' do
before do
vulnerability.description = nil
vulnerability.save!
end
it 'returns the description for the vulnerability finding' do
expect(subject.description).not_to eq(vulnerability.description)
expect(subject.description).to eq(finding.description)
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