diff options
Diffstat (limited to 'spec/helpers/markup_helper_spec.rb')
-rw-r--r-- | spec/helpers/markup_helper_spec.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index 1a720aae55c..d5ed5c59c61 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -205,7 +205,9 @@ describe MarkupHelper do it "uses Wiki pipeline for markdown files" do allow(@wiki).to receive(:format).and_return(:markdown) - expect(helper).to receive(:markdown_unsafe).with('wiki content', pipeline: :wiki, project: project, project_wiki: @wiki, page_slug: "nested/page", issuable_state_filter_enabled: true) + expect(helper).to receive(:markdown_unsafe).with('wiki content', + pipeline: :wiki, project: project, project_wiki: @wiki, page_slug: "nested/page", + issuable_state_filter_enabled: true, markdown_engine: :redcarpet) helper.render_wiki_content(@wiki) end @@ -236,19 +238,32 @@ describe MarkupHelper do expect(helper.markup('foo.rst', content).encoding.name).to eq('UTF-8') end - it "delegates to #markdown_unsafe when file name corresponds to Markdown" do + it 'delegates to #markdown_unsafe when file name corresponds to Markdown' do expect(helper).to receive(:gitlab_markdown?).with('foo.md').and_return(true) expect(helper).to receive(:markdown_unsafe).and_return('NOEL') expect(helper.markup('foo.md', content)).to eq('NOEL') end - it "delegates to #asciidoc_unsafe when file name corresponds to AsciiDoc" do + it 'delegates to #asciidoc_unsafe when file name corresponds to AsciiDoc' do expect(helper).to receive(:asciidoc?).with('foo.adoc').and_return(true) expect(helper).to receive(:asciidoc_unsafe).and_return('NOEL') expect(helper.markup('foo.adoc', content)).to eq('NOEL') end + + it 'uses passed in rendered content' do + expect(helper).not_to receive(:gitlab_markdown?) + expect(helper).not_to receive(:markdown_unsafe) + + expect(helper.markup('foo.md', content, rendered: '<p>NOEL</p>')).to eq('<p>NOEL</p>') + end + + it 'defaults to Redcarpet' do + expect(helper).to receive(:markdown_unsafe).with(content, hash_including(markdown_engine: :redcarpet)).and_return('NOEL') + + expect(helper.markup('foo.md', content)).to eq('NOEL') + end end describe '#first_line_in_markdown' do |