f986b4c4e5
This MR enables rendering of PlantUML diagrams in Asciidoc documents. To add a PlantUML diagram all we need is to include a plantuml block like: ``` [plantuml, id="myDiagram", width="100px", height="100px"] -- bob -> alice : ping alice -> bob : pong -- ``` The plantuml block is substituted by an HTML img element with *src* pointing to an external PlantUML server. This MR also add a PlantUML integration section to the Administrator -> Settings page to configure the PlantUML rendering service and to enable/disable it. Closes: #17603
50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
require 'spec_helper'
|
|
require 'nokogiri'
|
|
|
|
module Gitlab
|
|
describe Asciidoc, lib: true do
|
|
let(:input) { '<b>ascii</b>' }
|
|
let(:context) { {} }
|
|
let(:html) { 'H<sub>2</sub>O' }
|
|
|
|
context "without project" do
|
|
before do
|
|
allow_any_instance_of(ApplicationSetting).to receive(:current).and_return(::ApplicationSetting.create_from_defaults)
|
|
end
|
|
|
|
it "converts the input using Asciidoctor and default options" do
|
|
expected_asciidoc_opts = {
|
|
safe: :secure,
|
|
backend: :gitlab_html5,
|
|
attributes: described_class::DEFAULT_ADOC_ATTRS
|
|
}
|
|
|
|
expect(Asciidoctor).to receive(:convert)
|
|
.with(input, expected_asciidoc_opts).and_return(html)
|
|
|
|
expect( render(input, context) ).to eql html
|
|
end
|
|
|
|
context "with asciidoc_opts" do
|
|
let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } }
|
|
|
|
it "merges the options with default ones" do
|
|
expected_asciidoc_opts = {
|
|
safe: :safe,
|
|
backend: :gitlab_html5,
|
|
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo']
|
|
}
|
|
|
|
expect(Asciidoctor).to receive(:convert)
|
|
.with(input, expected_asciidoc_opts).and_return(html)
|
|
|
|
render(input, context, asciidoc_opts)
|
|
end
|
|
end
|
|
end
|
|
|
|
def render(*args)
|
|
described_class.render(*args)
|
|
end
|
|
end
|
|
end
|