Allow truncated_diff_lines to be called on image diff discussion
This commit is contained in:
parent
f6dd6e566a
commit
047b7e506e
2 changed files with 9 additions and 2 deletions
|
@ -39,6 +39,7 @@ module DiscussionOnDiff
|
|||
|
||||
# Returns an array of at most 16 highlighted lines above a diff note
|
||||
def truncated_diff_lines(highlight: true, diff_limit: nil)
|
||||
return [] unless on_text?
|
||||
return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote)
|
||||
|
||||
diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min
|
||||
|
|
|
@ -50,11 +50,17 @@ describe DiscussionOnDiff do
|
|||
end
|
||||
|
||||
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
|
||||
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([])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue