summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile.lock2
-rw-r--r--spec/lib/gitlab/highlight_spec.rb13
2 files changed, 8 insertions, 7 deletions
diff --git a/Gemfile.lock b/Gemfile.lock
index b03bd58eacc..4881faac0e0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -770,7 +770,7 @@ GEM
retriable (3.1.2)
rinku (2.0.0)
rotp (2.1.2)
- rouge (3.3.0)
+ rouge (3.4.1)
rqrcode (0.7.0)
chunky_png
rqrcode-rails3 (0.1.7)
diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb
index fe0e9702f8a..4676db6b8d8 100644
--- a/spec/lib/gitlab/highlight_spec.rb
+++ b/spec/lib/gitlab/highlight_spec.rb
@@ -18,9 +18,10 @@ describe Gitlab::Highlight do
end
describe '#highlight' do
+ let(:plain_text_file_name) { "test.txt" }
+ let(:plain_text_content) { "plain text contents" }
let(:file_name) { 'test.lisp' }
- let(:no_context_content) { ":type \"assem\"))" }
- let(:content) { "(make-pathname :defaults name\n#{no_context_content}" }
+ let(:content) { "(make-pathname :defaults name\n:type \"assem\")" }
let(:multiline_content) do
%q(
def test(input):
@@ -32,22 +33,22 @@ describe Gitlab::Highlight do
it 'highlights' do
expected = %Q[<span id="LC1" class="line" lang="common_lisp"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>
-<span id="LC2" class="line" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span>]
+<span id="LC2" class="line" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">)</span></span>]
expect(described_class.highlight(file_name, content)).to eq(expected)
end
it 'returns plain version for unknown lexer context' do
- result = described_class.highlight(file_name, no_context_content)
+ result = described_class.highlight(plain_text_file_name, plain_text_content)
- expect(result).to eq(%[<span id="LC1" class="line" lang="">:type "assem"))</span>])
+ expect(result).to eq(%[<span id="LC1" class="line" lang="plaintext">plain text contents</span>])
end
it 'returns plain version for long content' do
stub_const('Gitlab::Highlight::MAXIMUM_TEXT_HIGHLIGHT_SIZE', 1)
result = described_class.highlight(file_name, content)
- expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem"))</span>])
+ expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem")</span>])
end
it 'highlights multi-line comments' do