diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-01 10:30:46 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-01 10:30:46 +0000 |
commit | c1ee45953edac729bc43f676cfad3359f9b2a2f5 (patch) | |
tree | c6f3a8de12ea59f14ebeb0ff39c1f1bd5a4e152b /spec/helpers | |
parent | 8e4ba54aa44a5636684b2b99741e372d657d4316 (diff) | |
parent | b417fc0329ec10ccbaa1c282893f8710ff81db9d (diff) | |
download | gitlab-ce-c1ee45953edac729bc43f676cfad3359f9b2a2f5.tar.gz |
Merge branch 'fix_diff_line_comments' into 'master'
Fix: A diff comment on a change at last line of a file shows as two comments in discussion
Closes #32353
See merge request !11802
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 84341a51f2d..a74615e07f9 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -129,6 +129,33 @@ describe DiffHelper do end end + describe '#parallel_diff_discussions' do + let(:discussion) { { 'abc_3_3' => 'comment' } } + let(:diff_file) { double(line_code: 'abc_3_3') } + + before do + helper.instance_variable_set(:@grouped_diff_discussions, discussion) + end + + it 'does not put comments on nonewline lines' do + left = Gitlab::Diff::Line.new('\\nonewline', 'old-nonewline', 3, 3, 3) + right = Gitlab::Diff::Line.new('\\nonewline', 'new-nonewline', 3, 3, 3) + + result = helper.parallel_diff_discussions(left, right, diff_file) + + expect(result).to eq([nil, nil]) + end + + it 'puts comments on added lines' do + left = Gitlab::Diff::Line.new('\\nonewline', 'old-nonewline', 3, 3, 3) + right = Gitlab::Diff::Line.new('new line', 'add', 3, 3, 3) + + result = helper.parallel_diff_discussions(left, right, diff_file) + + expect(result).to eq([nil, 'comment']) + end + end + describe "#diff_match_line" do let(:old_pos) { 40 } let(:new_pos) { 50 } |