Commit 2d73fd0b authored by Nick Thomas's avatar Nick Thomas

Merge branch 'rf-fix-for-nil-location' into 'master'

Protect against empty location attribute

Closes #11512

See merge request gitlab-org/gitlab-ee!12342
parents 16a6c262 4fd296e9
......@@ -6,6 +6,7 @@ module Vulnerabilities
def blob_path
return '' unless respond_to?(:sha)
return '' unless location.present?
add_line_numbers(location['start_line'], location['end_line'])
end
......
......@@ -45,6 +45,15 @@ describe Vulnerabilities::OccurrencePresenter do
it { is_expected.to end_with('#L1-2') }
end
context 'without location' do
before do
allow(presenter).to receive(:location)
.and_return({})
end
it { is_expected.to be_blank }
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