Commit 3d701a7c authored by Patrick Bajao's avatar Patrick Bajao

Don't show image diff note on text file

parent 8775e4a1
---
title: Don't show image diff note on text file
merge_request: 30221
author:
type: fixed
......@@ -54,7 +54,7 @@ module Gitlab
def unfold_required?
strong_memoize(:unfold_required) do
next false unless @diff_file.text?
next false unless @position.unchanged?
next false unless @position.on_text? && @position.unchanged?
next false if @diff_file.new_file? || @diff_file.deleted_file?
next false unless @position.old_line
# Invalid position (MR import scenario)
......
......@@ -842,4 +842,37 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
end
context 'positioned on an image' do
let(:position) do
Gitlab::Diff::Position.new(
base_sha: '1c59dfa64afbea8c721bb09a06a9d326c952ea19',
start_sha: '1c59dfa64afbea8c721bb09a06a9d326c952ea19',
head_sha: '1487062132228de836236c522fe52fed4980a46c',
old_path: 'image.jpg',
new_path: 'image.jpg',
position_type: 'image'
)
end
before do
allow(old_blob).to receive(:binary?).and_return(binary?)
end
context 'diff file is not text' do
let(:binary?) { true }
it 'returns nil' do
expect(subject.unfolded_diff_lines).to be_nil
end
end
context 'diff file is text' do
let(:binary?) { false }
it 'returns nil' do
expect(subject.unfolded_diff_lines).to be_nil
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