summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-10 15:55:44 +0000
committerDouwe Maan <douwe@gitlab.com>2015-08-10 15:55:44 +0000
commit6e7bf50ba6d0d9eb896c1abef8dda8a4997c3088 (patch)
tree86471a94af7ad743e4c540c14b53a96cda21c38a /spec
parent39bda5d05e96ff9b2b8a89852b9520e8f262051e (diff)
parent15d5dfdb33c94ccfd7843f2be35bac2d74abe03e (diff)
downloadgitlab-ce-6e7bf50ba6d0d9eb896c1abef8dda8a4997c3088.tar.gz
Merge branch 'fix-diff-highlighting' into 'master'
Fix diff syntax highlighting ### What does this MR do? This MR fixes a syntax highlighting issue that that manifested itself when a user tried the following: ``` +aaa +bbb ccc ``` However, a regression in 0abe98f0 caused the last line to be put on the second to last line: ![image](https://gitlab.com/stanhu/gitlab-ce/uploads/a16515499d5e3fd9737370d89c73f671/image.png) Instead of this: ![image](https://gitlab.com/gitlab-org/gitlab-ce/uploads/59eca6efd4c290aa633b9fb54c98a70e/image.png) This bug occurred because of some error in the logic of handling new lines in the content. Refactored HTML parser to avoid duplication of newline parsing. ### What are the relevant issue numbers? Closes #2235 See merge request !1126
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/blob_helper_spec.rb16
-rw-r--r--spec/helpers/events_helper_spec.rb2
2 files changed, 17 insertions, 1 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
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb
index b392371deb4..da58ab98462 100644
--- a/spec/helpers/events_helper_spec.rb
+++ b/spec/helpers/events_helper_spec.rb
@@ -58,7 +58,7 @@ describe EventsHelper do
expected = '<pre class="code highlight white ruby">' \
"<code><span class=\"k\">def</span> <span class=\"nf\">test</span>\n" \
" <span class=\"s1\">\'hello world\'</span>\n" \
- "<span class=\"k\">end</span>\n" \
+ "<span class=\"k\">end</span>" \
'</code></pre>'
expect(event_note(input)).to eq(expected)
end