diff options
author | Sean McGivern <sean@gitlab.com> | 2016-07-29 13:29:14 +0100 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-08-12 23:24:43 +0300 |
commit | 7af277f683cd5ee0d5e3ffbc1dd3ce1d61f17848 (patch) | |
tree | e442df62fad56f5d907306ca8513a24a319d854b /spec/lib/gitlab/conflict | |
parent | d77216356a686029410c16d35775e42ef81a0e64 (diff) | |
download | gitlab-ce-7af277f683cd5ee0d5e3ffbc1dd3ce1d61f17848.tar.gz |
Auto-highlight conflict when rich_text is called
Diffstat (limited to 'spec/lib/gitlab/conflict')
-rw-r--r-- | spec/lib/gitlab/conflict/file_spec.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb index afdb52daf43..735b5b34623 100644 --- a/spec/lib/gitlab/conflict/file_spec.rb +++ b/spec/lib/gitlab/conflict/file_spec.rb @@ -63,17 +63,23 @@ describe Gitlab::Conflict::File, lib: true do end end - describe '#highlighted_lines' do + describe '#highlight_lines!' do def html_to_text(html) CGI.unescapeHTML(ActionView::Base.full_sanitizer.sanitize(html)).delete("\n") end - it 'returns lines with rich_text' do - expect(conflict_file.highlighted_lines).to all(have_attributes(rich_text: a_kind_of(String))) + it 'modifies the existing lines' do + expect { conflict_file.highlight_lines! }.to change { conflict_file.lines.map(&:instance_variables) } end - it 'returns lines with rich_text matching the text content of the line' do - conflict_file.highlighted_lines.each do |line| + it 'is called implicitly when rich_text is accessed on a line' do + expect(conflict_file).to receive(:highlight_lines!).once.and_call_original + + conflict_file.lines.each(&:rich_text) + end + + it 'sets the rich_text of the lines matching the text content' do + conflict_file.lines.each do |line| expect(line.text).to eq(html_to_text(line.rich_text)) end end |