Commit 7dbbb6de authored by Marin Jankovski's avatar Marin Jankovski

Rename method to avoid clashes.

parent 70f828cd
...@@ -75,12 +75,12 @@ module GitlabMarkdownHelper ...@@ -75,12 +75,12 @@ module GitlabMarkdownHelper
def new_link(path_with_namespace, string, ref) def new_link(path_with_namespace, string, ref)
[ [
path_with_namespace, path_with_namespace,
path(string, ref), path_with_ref(string, ref),
string string
].compact.join("/") ].compact.join("/")
end end
def path(string, ref) def path_with_ref(string, ref)
if File.exists?(Rails.root.join(string)) if File.exists?(Rails.root.join(string))
"#{local_path(string)}/#{correct_ref(ref)}" "#{local_path(string)}/#{correct_ref(ref)}"
else else
......
...@@ -406,6 +406,30 @@ describe GitlabMarkdownHelper do ...@@ -406,6 +406,30 @@ describe GitlabMarkdownHelper do
it "should generate absolute urls for emoji" do it "should generate absolute urls for emoji" do
markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}") markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}")
end 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 end
describe "#render_wiki_content" do describe "#render_wiki_content" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment