diff options
author | Sean McGivern <sean@gitlab.com> | 2016-08-04 14:12:08 +0100 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-08-12 23:24:48 +0300 |
commit | ac9229a31be8e672efdcc63b702a2039ae66ad46 (patch) | |
tree | dc27c3ac2730c2b7a91e6f0fbe532d293476b302 /spec/lib/gitlab/conflict | |
parent | 427e724698185169536d68e95873415038286849 (diff) | |
download | gitlab-ce-ac9229a31be8e672efdcc63b702a2039ae66ad46.tar.gz |
Clarify Conflict::File#sections method
Diffstat (limited to 'spec/lib/gitlab/conflict')
-rw-r--r-- | spec/lib/gitlab/conflict/file_spec.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index cf670b3182a..405b97686f5 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -86,19 +86,20 @@ describe Gitlab::Conflict::File, lib: true do end describe '#sections' do - it 'returns match lines when there is a gap between sections' do - section = conflict_file.sections[5] - match_line = section[:lines][0] + it 'only inserts match lines when there is a gap between sections' do + conflict_file.sections.each_with_index do |section, i| + previous_line_number = 0 + current_line_number = section[:lines].map(&:old_line).compact.min - expect(section[:conflict]).to be_falsey - expect(match_line.type).to eq('match') - expect(match_line.text).to eq('@@ -46,53 +46,53 @@ module Gitlab') - end + if i > 0 + previous_line_number = conflict_file.sections[i - 1][:lines].map(&:old_line).compact.last + end - it 'does not return match lines when there is no gap between sections' do - conflict_file.sections.each_with_index do |section, i| - unless i == 5 - expect(section[:lines][0].type).not_to eq(5) + if current_line_number == previous_line_number + 1 + expect(section[:lines].first.type).not_to eq('match') + else + expect(section[:lines].first.type).to eq('match') + expect(section[:lines].first.text).to match(/\A@@ -#{current_line_number},\d+ \+\d+,\d+ @@ module Gitlab\Z/) end end end |