BigW Consortium Gitlab

Commit 721a26d9 by Douwe Maan Committed by Robert Speicher

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
parent 74b3192a
......@@ -37,6 +37,8 @@ module DiscussionOnDiff
# 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 @@ describe DiscussionOnDiff do
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