Commit 3d9d3567 authored by Dmytro Zaporozhets's avatar Dmytro Zaporozhets

Merge branch...

Merge branch '28376-merge-request-comments-have-stopped-appearing-for-the-whole-project' into 'master'

Fix for invalid diff lines on corrupt diff notes

See merge request gitlab-org/gitlab!23786
parents ecd631f1 3f02ca1e
...@@ -40,7 +40,7 @@ module DiscussionOnDiff ...@@ -40,7 +40,7 @@ module DiscussionOnDiff
# Returns an array of at most 16 highlighted lines above a diff note # Returns an array of at most 16 highlighted lines above a diff note
def truncated_diff_lines(highlight: true, diff_limit: nil) def truncated_diff_lines(highlight: true, diff_limit: nil)
return [] unless on_text? return [] unless on_text?
return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote) return [] if diff_line.nil?
diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min
lines = highlight ? highlighted_diff_lines : diff_lines lines = highlight ? highlighted_diff_lines : diff_lines
......
---
title: Fix Merge Request comments when some notes are corrupt
merge_request: 23786
author:
type: fixed
...@@ -59,6 +59,18 @@ describe DiscussionOnDiff do ...@@ -59,6 +59,18 @@ describe DiscussionOnDiff do
end end
end end
context "when the diff line does not exist on a corrupt diff note" do
subject { create(:diff_note_on_merge_request, line_number: 18).to_discussion }
before do
allow(subject).to receive(:diff_line) { nil }
end
it "returns an empty array" do
expect(truncated_lines).to eq([])
end
end
context 'when the discussion is on an image' do context 'when the discussion is on an image' do
subject { create(:image_diff_note_on_merge_request).to_discussion } subject { create(:image_diff_note_on_merge_request).to_discussion }
......
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