Commit 047b7e50 authored by Douwe Maan's avatar Douwe Maan

Allow truncated_diff_lines to be called on image diff discussion

parent f6dd6e56
...@@ -39,6 +39,7 @@ module DiscussionOnDiff ...@@ -39,6 +39,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 [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote) return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote)
diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min
......
...@@ -50,11 +50,17 @@ describe DiscussionOnDiff do ...@@ -50,11 +50,17 @@ describe DiscussionOnDiff do
end end
context "when the diff line does not exist on a legacy diff note" do context "when the diff line does not exist on a legacy diff note" do
subject { create(:legacy_diff_note_on_merge_request).to_discussion }
it "returns an empty array" do it "returns an empty array" do
legacy_note = LegacyDiffNote.new expect(truncated_lines).to eq([])
end
end
allow(subject).to receive(:first_note).and_return(legacy_note) context 'when the discussion is on an image' do
subject { create(:image_diff_note_on_merge_request).to_discussion }
it 'returns an empty array' do
expect(truncated_lines).to eq([]) expect(truncated_lines).to eq([])
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