Commit b880e5df authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '8596-fix_title_and_description_for_issue_created_from_vulnerability' into 'master'

Fix title and description for issue created from vulnerability

Closes #8596

See merge request gitlab-org/gitlab-ee!9022
parents 0094a007 28aaf40d
---
title: Fix title and description for issue created from a vulnerability
merge_request: 9022
author:
type: fixed
......@@ -5,7 +5,6 @@ module Gitlab
class StandardVulnerability < BaseVulnerability
# Passthrough properties
%i[
title
severity
confidence
solution
......@@ -17,8 +16,12 @@ module Gitlab
end
end
def title
@data[:title].presence || @data[:name]
end
def description
@data[:description].presence || @data[:title]
@data[:description].presence || title
end
def file
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Vulnerabilities::StandardVulnerability do
let(:title) { 'Predictable pseudorandom number generator' }
let(:name) { 'Predictable pseudorandom number generator (from name)' }
let(:description) { 'Description of Predictable pseudorandom number generator' }
let(:severity) { 'Low' }
let(:confidence) { 'High' }
......@@ -37,24 +38,6 @@ describe Gitlab::Vulnerabilities::StandardVulnerability do
expect(vulnerability).to be_kind_of(Gitlab::Vulnerabilities::BaseVulnerability)
end
describe '#title' do
context 'when title is present' do
it 'returns title' do
vulnerability = described_class.new(title: title)
expect(vulnerability.title).to eq title
end
end
context 'when title is not set' do
it 'returns nil' do
vulnerability = described_class.new(foo: 'bar')
expect(vulnerability.title).to be_nil
end
end
end
describe '#severity' do
context 'when severity is present' do
it 'returns severity' do
......@@ -145,6 +128,32 @@ describe Gitlab::Vulnerabilities::StandardVulnerability do
end
end
describe '#title' do
context 'when title is present' do
it 'returns title' do
vulnerability = described_class.new(title: title)
expect(vulnerability.title).to eq title
end
end
context 'when title is not set' do
it 'fallbacks to name' do
vulnerability = described_class.new(name: name)
expect(vulnerability.title).to eq name
end
end
context 'when title and name are not set' do
it 'returns nil' do
vulnerability = described_class.new(foo: 'bar')
expect(vulnerability.title).to be_nil
end
end
end
describe '#description' do
context 'when description is present' do
it 'returns description' do
......@@ -156,13 +165,21 @@ describe Gitlab::Vulnerabilities::StandardVulnerability do
context 'when description is not set' do
it 'fallbacks to title' do
vulnerability = described_class.new(title: title)
vulnerability = described_class.new(title: title, name: name)
expect(vulnerability.description).to eq title
end
end
context 'when title and description are not set' do
context 'when description and title are not set' do
it 'fallbacks to name' do
vulnerability = described_class.new(name: name)
expect(vulnerability.description).to eq name
end
end
context 'when title, name and description are not set' do
it 'returns nil' do
vulnerability = described_class.new(foo: 'bar')
......
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