diff options
author | Stan Hu <stanhu@gmail.com> | 2015-08-10 09:08:28 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-08-10 18:07:26 +0300 |
commit | 15d5dfdb33c94ccfd7843f2be35bac2d74abe03e (patch) | |
tree | e832e49912d8a8082a686b0781b55423e368cb3e /spec/helpers/blob_helper_spec.rb | |
parent | 77f37fa9094443abe8e60ebd09a82e94d0a0047b (diff) |
Fix diff syntax highlighting
Refactored HTML parser to avoid duplication of newline parsing.
Closes #2235
Diffstat (limited to 'spec/helpers/blob_helper_spec.rb')
-rw-r--r-- | spec/helpers/blob_helper_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb index 76009c36099..b8bba36439a 100644 --- a/spec/helpers/blob_helper_spec.rb +++ b/spec/helpers/blob_helper_spec.rb @@ -47,5 +47,21 @@ describe BlobHelper do expect(lines[1].text).to eq(' This is line 2.') expect(lines[2].text).to eq(' """') end + + context 'diff highlighting' do + let(:blob_name) { 'test.diff' } + let(:blob_content) { "+aaa\n+bbb\n- ccc\n ddd\n"} + let(:expected) do + %q(<span id="LC1" class="line"><span class="gi">+aaa</span></span> +<span id="LC2" class="line"><span class="gi">+bbb</span></span> +<span id="LC3" class="line"><span class="gd">- ccc</span></span> +<span id="LC4" class="line"> ddd</span>) + end + + it 'should highlight each line properly' do + result = highlight(blob_name, blob_content, nowrap: true, continue: false) + expect(result).to eq(expected) + end + end end end |