diff options
author | Stan Hu <stanhu@gmail.com> | 2015-09-10 18:23:10 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-09-10 19:16:27 +0300 |
commit | 9d3344adbbfc84ef8abc96366bdfa695293cd6c0 (patch) | |
tree | efe45a503b814013a06d8e77b112b74c6ec4d6a9 /spec | |
parent | 1c3c3ba512a85cdf0c09ac4750bcd7955009d6d4 (diff) |
Gracefully handle errors in syntax highlighting by leaving the block unformatted
Closes #2433
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb b/spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb new file mode 100644 index 00000000000..ecef31853f4 --- /dev/null +++ b/spec/lib/gitlab/markdown/syntax_highlight_filter_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +module Gitlab::Markdown + describe SyntaxHighlightFilter do + include FilterSpecHelper + + let(:project) { create(:empty_project) } + let(:reference) { snippet.to_reference } + + it 'highlights valid code blocks' do + result = filter('<pre><code>def fun end</code>') + expect(result.to_html).to eq("<pre class=\"code highlight js-syntax-highlight plaintext\"><code>def fun end</code></pre>\n") + end + + it 'passes through invalid code blocks' do + allow_any_instance_of(SyntaxHighlightFilter).to receive(:block_code).and_raise(StandardError) + + result = filter('<pre><code>This is a test</code></pre>') + expect(result.to_html).to eq('<pre>This is a test</pre>') + end + end +end |