diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-06-28 22:49:54 +0200 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-06-28 22:53:35 +0200 |
commit | 26a8472d6d0aa1eb40285105a0f55f2f7d439897 (patch) | |
tree | 6a63bfe557716bf8a64bc7ce26eb6724236cc330 /spec | |
parent | 9ad97abfec59cde15b240a5e81a1b1caf1b2a4fc (diff) | |
download | gitlab-ce-26a8472d6d0aa1eb40285105a0f55f2f7d439897.tar.gz |
Don't add bottom 'match' line for deleted files
If a file is deleted, its new_pos is 0 (less than
total_blob_lines), but there is no reason to add the
bottom 'match' line in this case because there is not
extra content which could be expanded.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/diff/file_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index 5dfbb8e71f8..ebeb05d6e02 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -26,6 +26,21 @@ describe Gitlab::Diff::File do end end + describe '#diff_lines_for_serializer' do + it 'includes bottom match line if not in the end' do + expect(diff_file.diff_lines_for_serializer.last.type).to eq('match') + end + + context 'when deleted' do + let(:commit) { project.commit('d59c60028b053793cecfb4022de34602e1a9218e') } + let(:diff_file) { commit.diffs.diff_file_with_old_path('files/js/commit.js.coffee') } + + it 'does not include bottom match line' do + expect(diff_file.diff_lines_for_serializer.last.type).not_to eq('match') + end + end + end + describe '#mode_changed?' do it { expect(diff_file.mode_changed?).to be_falsey } end |