diff options
author | Horacio Sanson <horacio@allm.net> | 2017-01-16 09:07:02 +0900 |
---|---|---|
committer | Horacio Sanson <horacio@allm.net> | 2017-02-03 08:49:48 +0900 |
commit | d9e9ad2211c06159914e0183e4842abc16e5666f (patch) | |
tree | ffa7e02948f10a42b42d33d3b568774c147bd98c /spec/lib | |
parent | e7d530a624fbb8854047c3983eaa0972a19f36c8 (diff) | |
download | gitlab-ce-d9e9ad2211c06159914e0183e4842abc16e5666f.tar.gz |
PlantUML support for Markdown
Allow rendering of PlantUML diagrams in Markdown documents using fenced blocks:
```plantuml
Bob -> Sara : Hello
Sara -> Bob : Go away
```
Closes: #4048
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/banzai/filter/plantuml_filter_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/plantuml_filter_spec.rb b/spec/lib/banzai/filter/plantuml_filter_spec.rb new file mode 100644 index 00000000000..f85a5dcbd8b --- /dev/null +++ b/spec/lib/banzai/filter/plantuml_filter_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Banzai::Filter::PlantumlFilter, lib: true do + include FilterSpecHelper + + it 'should replace plantuml pre tag with img tag' do + stub_application_setting(plantuml_enabled: true, plantuml_url: "http://localhost:8080") + input = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre>' + output = '<div class="imageblock"><div class="content"><img class="plantuml" src="http://localhost:8080/png/U9npoazIqBLJ24uiIbImKl18pSd91m0rkGMq"></div></div>' + doc = filter(input) + + expect(doc.to_s).to eq output + end + + it 'should not replace plantuml pre tag with img tag if disabled' do + stub_application_setting(plantuml_enabled: false) + input = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre>' + output = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre></pre></pre>' + doc = filter(input) + + expect(doc.to_s).to eq output + end + + it 'should not replace plantuml pre tag with img tag if url is invalid' do + stub_application_setting(plantuml_enabled: true, plantuml_url: "invalid") + input = '<pre class="plantuml"><code>Bob -> Sara : Hello</code><pre>' + output = '<div class="listingblock"><div class="content"><pre class="plantuml plantuml-error"> PlantUML Error: cannot connect to PlantUML server at "invalid"</pre></div></div>' + doc = filter(input) + + expect(doc.to_s).to eq output + end +end |