summaryrefslogtreecommitdiff
path: root/spec/helpers/markup_helper_spec.rb
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-04-06 16:47:52 +0200
committerToon Claes <toon@gitlab.com>2017-04-27 13:22:17 +0200
commit05e0f504530a162d4bcb886adf504c12cffd5934 (patch)
treeaeece92fb84421062c919e0c63173718db3577ba /spec/helpers/markup_helper_spec.rb
parentef4d4446e957ecbb086859d96185a27af168d11c (diff)
downloadgitlab-ce-05e0f504530a162d4bcb886adf504c12cffd5934.tar.gz
Cache the rendered README, but post-process on show
Because the post-processing of the rendered README is dependent on the context (i.e. the current user), do the post-processing when the README is being displayed.
Diffstat (limited to 'spec/helpers/markup_helper_spec.rb')
-rw-r--r--spec/helpers/markup_helper_spec.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index 617cfed5bee..59ae6570ae7 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -126,15 +126,16 @@ describe MarkupHelper do
it "uses Wiki pipeline for markdown files" do
allow(@wiki).to receive(:format).and_return(:markdown)
- expect(helper).to receive(:markdown).with('wiki content', pipeline: :wiki, project_wiki: @wiki, page_slug: "nested/page")
+ expect(helper).to receive(:markdown_render).with('wiki content', pipeline: :wiki, project_wiki: @wiki, page_slug: "nested/page")
helper.render_wiki_content(@wiki)
end
it "uses Asciidoctor for asciidoc files" do
+ allow_any_instance_of(ApplicationSetting).to receive(:current).and_return(::ApplicationSetting.create_from_defaults)
allow(@wiki).to receive(:format).and_return(:asciidoc)
- expect(helper).to receive(:asciidoc).with('wiki content')
+ expect(helper).to receive(:asciidoc_render).with('wiki content')
helper.render_wiki_content(@wiki)
end
@@ -149,6 +150,29 @@ describe MarkupHelper do
end
end
+ describe 'render_markup' do
+ let(:content) { 'Noël' }
+
+ it 'preserves encoding' do
+ expect(content.encoding.name).to eq('UTF-8')
+ expect(helper.render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
+ end
+
+ it "delegates to #markdown_render when file name corresponds to Markdown" do
+ expect(helper).to receive(:gitlab_markdown?).with('foo.md').and_return(true)
+ expect(helper).to receive(:markdown_render).and_return('NOEL')
+
+ expect(helper.render_markup('foo.md', content)).to eq('NOEL')
+ end
+
+ it "delegates to #asciidoc_render when file name corresponds to AsciiDoc" do
+ expect(helper).to receive(:asciidoc?).with('foo.adoc').and_return(true)
+ expect(helper).to receive(:asciidoc_render).and_return('NOEL')
+
+ expect(helper.render_markup('foo.adoc', content)).to eq('NOEL')
+ end
+ end
+
describe '#first_line_in_markdown' do
it 'truncates Markdown properly' do
text = "@#{user.username}, can you look at this?\nHello world\n"