diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/lib/gitlab/conflict/file_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/lib/gitlab/conflict/file_spec.rb')
-rw-r--r-- | spec/lib/gitlab/conflict/file_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index 80bd517ec92..0de944d3f8a 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -93,6 +93,51 @@ RSpec.describe Gitlab::Conflict::File do end end + describe '#diff_lines_for_serializer' do + let(:diff_line_types) { conflict_file.diff_lines_for_serializer.map(&:type) } + + it 'assigns conflict types to the diff lines' do + expect(diff_line_types[4]).to eq('conflict_marker') + expect(diff_line_types[5..10]).to eq(['conflict_marker_our'] * 6) + expect(diff_line_types[11]).to eq('conflict_marker') + expect(diff_line_types[12..17]).to eq(['conflict_marker_their'] * 6) + expect(diff_line_types[18]).to eq('conflict_marker') + + expect(diff_line_types[19..24]).to eq([nil] * 6) + + expect(diff_line_types[25]).to eq('conflict_marker') + expect(diff_line_types[26..27]).to eq(['conflict_marker_our'] * 2) + expect(diff_line_types[28]).to eq('conflict_marker') + expect(diff_line_types[29..30]).to eq(['conflict_marker_their'] * 2) + expect(diff_line_types[31]).to eq('conflict_marker') + end + + it 'does not add a match line to the end of the section' do + expect(diff_line_types.last).to eq(nil) + end + + context 'when there are unchanged trailing lines' do + let(:rugged_conflict) { index.conflicts.first } + let(:raw_conflict_content) { index.merge_file('files/ruby/popen.rb')[:data] } + + it 'assign conflict types and adds match line to the end of the section' do + expect(diff_line_types).to eq([ + 'match', + nil, nil, nil, + "conflict_marker", + "conflict_marker_our", + "conflict_marker", + "conflict_marker_their", + "conflict_marker_their", + "conflict_marker_their", + "conflict_marker", + nil, nil, nil, + "match" + ]) + end + end + end + describe '#sections' do it 'only inserts match lines when there is a gap between sections' do conflict_file.sections.each_with_index do |section, i| |