提交 7dbbb6de 编写于 作者: M Marin Jankovski

Rename method to avoid clashes.

上级 70f828cd
......@@ -75,12 +75,12 @@ module GitlabMarkdownHelper
def new_link(path_with_namespace, string, ref)
[
path_with_namespace,
path(string, ref),
path_with_ref(string, ref),
string
].compact.join("/")
end
def path(string, ref)
def path_with_ref(string, ref)
if File.exists?(Rails.root.join(string))
"#{local_path(string)}/#{correct_ref(ref)}"
else
......
......@@ -406,6 +406,30 @@ describe GitlabMarkdownHelper do
it "should generate absolute urls for emoji" do
markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}")
end
it "should handle relative urls for a file in master" do
actual = "[GitLab API doc](doc/api/README.md)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/master/doc/api/README.md\">GitLab API doc</a></p>\n"
markdown(actual).should match(expected)
end
it "should handle relative urls for a directory in master" do
actual = "[GitLab API doc](doc/api)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/master/doc/api\">GitLab API doc</a></p>\n"
markdown(actual).should match(expected)
end
it "should handle absolute urls" do
actual = "[GitLab](https://www.gitlab.com)\n"
expected = "<p><a href=\"https://www.gitlab.com\">GitLab</a></p>\n"
markdown(actual).should match(expected)
end
it "should handle wiki urls" do
actual = "[Link](test/link)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/wikis/test/link\">Link</a></p>\n"
markdown(actual).should match(expected)
end
end
describe "#render_wiki_content" do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册