diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/lib/banzai/filter/plantuml_filter_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/lib/banzai/filter/plantuml_filter_spec.rb')
-rw-r--r-- | spec/lib/banzai/filter/plantuml_filter_spec.rb | 72 |
1 files changed, 19 insertions, 53 deletions
diff --git a/spec/lib/banzai/filter/plantuml_filter_spec.rb b/spec/lib/banzai/filter/plantuml_filter_spec.rb index e1e02c09fbe..2d1a01116e0 100644 --- a/spec/lib/banzai/filter/plantuml_filter_spec.rb +++ b/spec/lib/banzai/filter/plantuml_filter_spec.rb @@ -5,67 +5,33 @@ require 'spec_helper' RSpec.describe Banzai::Filter::PlantumlFilter do include FilterSpecHelper - shared_examples_for 'renders correct markdown' do - it 'replaces plantuml pre tag with img tag' do - stub_application_setting(plantuml_enabled: true, plantuml_url: "http://localhost:8080") + it 'replaces plantuml pre tag with img tag' do + stub_application_setting(plantuml_enabled: true, plantuml_url: "http://localhost:8080") - input = if Feature.enabled?(:use_cmark_renderer, default_enabled: :yaml) - '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' - else - '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>' - end + input = '<pre lang="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) - 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 'does not replace plantuml pre tag with img tag if disabled' do - stub_application_setting(plantuml_enabled: false) - - if Feature.enabled?(:use_cmark_renderer, default_enabled: :yaml) - input = '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' - output = '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' - else - input = '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>' - output = '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>' - end - - doc = filter(input) - - expect(doc.to_s).to eq output - end - - it 'does not replace plantuml pre tag with img tag if url is invalid' do - stub_application_setting(plantuml_enabled: true, plantuml_url: "invalid") + expect(doc.to_s).to eq output + end - input = if Feature.enabled?(:use_cmark_renderer, default_enabled: :yaml) - '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' - else - '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>' - end + it 'does not replace plantuml pre tag with img tag if disabled' do + stub_application_setting(plantuml_enabled: false) - output = '<div class="listingblock"><div class="content"><pre class="plantuml plantuml-error"> Error: cannot connect to PlantUML server at "invalid"</pre></div></div>' - doc = filter(input) + input = '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' + output = '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' + doc = filter(input) - expect(doc.to_s).to eq output - end + expect(doc.to_s).to eq output end - context 'using ruby-based HTML renderer' do - before do - stub_feature_flags(use_cmark_renderer: false) - end - - it_behaves_like 'renders correct markdown' - end + it 'does not replace plantuml pre tag with img tag if url is invalid' do + stub_application_setting(plantuml_enabled: true, plantuml_url: "invalid") - context 'using c-based HTML renderer' do - before do - stub_feature_flags(use_cmark_renderer: true) - end + input = '<pre lang="plantuml"><code>Bob -> Sara : Hello</code></pre>' + output = '<div class="listingblock"><div class="content"><pre class="plantuml plantuml-error"> Error: cannot connect to PlantUML server at "invalid"</pre></div></div>' + doc = filter(input) - it_behaves_like 'renders correct markdown' + expect(doc.to_s).to eq output end end |