Skip to content
代码片段 群组 项目
提交 31d1e166 编辑于 作者: Nicolas Dular's avatar Nicolas Dular
浏览文件

Merge branch '282479-add-spec-for-missing-methods-vulnerability-presenter' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -13,8 +13,27 @@
let_it_be(:finding2) { create(:vulnerabilities_finding, :with_secret_detection, scan: sast_scan) }
let_it_be(:vulnerability_links) do
[
{ name: 'link1', url: 'www.example.com/link1' },
{ name: 'link2', url: 'www.exampple.com/link2' }
]
end
subject { described_class.new(finding.vulnerability) }
describe '#links' do
context 'when vulnerability has links' do
before do
allow(finding.vulnerability).to receive(:links).and_return(vulnerability_links)
end
it 'expect links to be instance of active support hash with indifferent access' do
expect(subject.links).to all(be_a(ActiveSupport::HashWithIndifferentAccess))
end
end
end
describe '#scanner' do
it 'returns the scanner for a finding' do
expect(subject.scanner).to eql(finding.scanner)
......@@ -47,6 +66,22 @@
end
end
describe '#location_text' do
context 'when line is nil' do
it 'returns a string with file' do
allow(subject).to receive(:line).and_return(nil)
expect(subject.location_text).to eq finding.file
end
end
context 'when line is present' do
it 'returns a string with file and line' do
expect(subject.location_text).to eq "#{finding.file}:#{finding.location['start_line']}"
end
end
end
describe '#location_link_with_raw_path' do
context 'when the end_line is the same as the start_line' do
it 'returns the location link in raw format' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册