Commit 7dbbb6defeba71892230b20c5d1390f94ae1f719
1 parent
70f828cd
Exists in
master
and in
4 other branches
Rename method to avoid clashes.
Showing
2 changed files
with
26 additions
and
2 deletions
Show diff stats
app/helpers/gitlab_markdown_helper.rb
@@ -75,12 +75,12 @@ module GitlabMarkdownHelper | @@ -75,12 +75,12 @@ module GitlabMarkdownHelper | ||
75 | def new_link(path_with_namespace, string, ref) | 75 | def new_link(path_with_namespace, string, ref) |
76 | [ | 76 | [ |
77 | path_with_namespace, | 77 | path_with_namespace, |
78 | - path(string, ref), | 78 | + path_with_ref(string, ref), |
79 | string | 79 | string |
80 | ].compact.join("/") | 80 | ].compact.join("/") |
81 | end | 81 | end |
82 | 82 | ||
83 | - def path(string, ref) | 83 | + def path_with_ref(string, ref) |
84 | if File.exists?(Rails.root.join(string)) | 84 | if File.exists?(Rails.root.join(string)) |
85 | "#{local_path(string)}/#{correct_ref(ref)}" | 85 | "#{local_path(string)}/#{correct_ref(ref)}" |
86 | else | 86 | else |
spec/helpers/gitlab_markdown_helper_spec.rb
@@ -406,6 +406,30 @@ describe GitlabMarkdownHelper do | @@ -406,6 +406,30 @@ describe GitlabMarkdownHelper do | ||
406 | it "should generate absolute urls for emoji" do | 406 | it "should generate absolute urls for emoji" do |
407 | markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}") | 407 | markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}") |
408 | end | 408 | end |
409 | + | ||
410 | + it "should handle relative urls for a file in master" do | ||
411 | + actual = "[GitLab API doc](doc/api/README.md)\n" | ||
412 | + expected = "<p><a href=\"/#{project.path_with_namespace}/blob/master/doc/api/README.md\">GitLab API doc</a></p>\n" | ||
413 | + markdown(actual).should match(expected) | ||
414 | + end | ||
415 | + | ||
416 | + it "should handle relative urls for a directory in master" do | ||
417 | + actual = "[GitLab API doc](doc/api)\n" | ||
418 | + expected = "<p><a href=\"/#{project.path_with_namespace}/tree/master/doc/api\">GitLab API doc</a></p>\n" | ||
419 | + markdown(actual).should match(expected) | ||
420 | + end | ||
421 | + | ||
422 | + it "should handle absolute urls" do | ||
423 | + actual = "[GitLab](https://www.gitlab.com)\n" | ||
424 | + expected = "<p><a href=\"https://www.gitlab.com\">GitLab</a></p>\n" | ||
425 | + markdown(actual).should match(expected) | ||
426 | + end | ||
427 | + | ||
428 | + it "should handle wiki urls" do | ||
429 | + actual = "[Link](test/link)\n" | ||
430 | + expected = "<p><a href=\"/#{project.path_with_namespace}/wikis/test/link\">Link</a></p>\n" | ||
431 | + markdown(actual).should match(expected) | ||
432 | + end | ||
409 | end | 433 | end |
410 | 434 | ||
411 | describe "#render_wiki_content" do | 435 | describe "#render_wiki_content" do |