Commit 355758b1 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch...

Merge branch '42160-error-500-loading-merge-request-undefined-method-index-for-nil-nilclass' into 'master'

Resolve "Error 500 loading merge request: undefined method `index' for nil:NilClass"

Closes #42160

See merge request gitlab-org/gitlab-ce!16795
......@@ -37,6 +37,8 @@ def on_merge_request_commit?
# Returns an array of at most 16 highlighted lines above a diff note
def truncated_diff_lines(highlight: true)
return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote)
lines = highlight ? highlighted_diff_lines : diff_lines
initial_line_index = [diff_line.index - NUMBER_OF_TRUNCATED_DIFF_LINES + 1, 0].max
......
---
title: Fix 500 error when loading a merge request with an invalid comment
merge_request: 16795
author:
type: fixed
......@@ -20,6 +20,16 @@
expect(truncated_lines).not_to include(be_meta)
end
end
context "when the diff line does not exist on a legacy diff note" do
it "returns an empty array" do
legacy_note = LegacyDiffNote.new
allow(subject).to receive(:first_note).and_return(legacy_note)
expect(truncated_lines).to eq([])
end
end
end
describe '#line_code_in_diffs' do
......
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