Commit 5e59d0b5 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'rf-guard-against-nil-file' into 'master'

Guard against nil file key

Closes #11512

See merge request gitlab-org/gitlab-ee!12418
parents 65d6b7e3 95ea0ba4
......@@ -6,7 +6,7 @@ module Vulnerabilities
def blob_path
return '' unless respond_to?(:sha)
return '' unless location.present?
return '' unless location.present? && location['file'].present?
add_line_numbers(location['start_line'], location['end_line'])
end
......
......@@ -46,6 +46,15 @@ describe Vulnerabilities::OccurrencePresenter do
it { is_expected.to end_with('#L1-2') }
end
context 'without file' do
before do
allow(presenter).to receive(:location)
.and_return({ 'foo' => 123 })
end
it { is_expected.to be_blank }
end
context 'without location' do
before do
allow(presenter).to receive(:location)
......
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