Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/helpers/gitlab_markdown_helper.rb8
-rw-r--r--app/views/wikis/show.html.haml2
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb24
3 files changed, 33 insertions, 1 deletions
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb
index 1a3d34eb886..375f8861dae 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/gitlab_markdown_helper.rb
@@ -49,4 +49,12 @@ module GitlabMarkdownHelper
@markdown.render(text).html_safe
end
+
+ def render_wiki_content(wiki_page)
+ if wiki_page.format == :markdown
+ markdown(wiki_page.content)
+ else
+ wiki_page.formatted_content.html_safe
+ end
+ end
end
diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml
index 54d2a728504..8e9870698ae 100644
--- a/app/views/wikis/show.html.haml
+++ b/app/views/wikis/show.html.haml
@@ -10,7 +10,7 @@
.file_holder
.file_content.wiki
= preserve do
- = @wiki.formatted_content.html_safe
+ = render_wiki_content(@wiki)
- commit = CommitDecorator.new(@wiki.version)
%p.time Last edited by #{commit.author_link(avatar: true, size: 16)} #{time_ago_in_words @wiki.created_at} ago
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 1f5fabfbb8e..ac49e4d6da0 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -363,4 +363,28 @@ describe GitlabMarkdownHelper do
markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}")
end
end
+
+ describe "#render_wiki_content" do
+ before do
+ @wiki = stub('WikiPage')
+ @wiki.stub(:content).and_return('wiki content')
+ end
+
+ it "should use Gitlab Flavored Markdown for markdown files" do
+ @wiki.stub(:format).and_return(:markdown)
+
+ helper.should_receive(:markdown).with('wiki content')
+
+ helper.render_wiki_content(@wiki)
+ end
+
+ it "should use the Gollum renderer for all other file types" do
+ @wiki.stub(:format).and_return(:rdoc)
+ formatted_content_stub = stub('formatted_content')
+ formatted_content_stub.should_receive(:html_safe)
+ @wiki.stub(:formatted_content).and_return(formatted_content_stub)
+
+ helper.render_wiki_content(@wiki)
+ end
+ end
end