Commit 7635afd0 authored by Riyad Preukschas's avatar Riyad Preukschas

Use Urls for references in GFM

parent 640d51f4
...@@ -147,31 +147,31 @@ module Gitlab ...@@ -147,31 +147,31 @@ module Gitlab
def reference_user(identifier) def reference_user(identifier)
if member = @project.users_projects.joins(:user).where(users: { username: identifier }).first if member = @project.users_projects.joins(:user).where(users: { username: identifier }).first
link_to("@#{identifier}", project_team_member_path(@project, member), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member link_to("@#{identifier}", project_team_member_url(@project, member), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member
end end
end end
def reference_issue(identifier) def reference_issue(identifier)
if issue = @project.issues.where(id: identifier).first if issue = @project.issues.where(id: identifier).first
link_to("##{identifier}", project_issue_path(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) link_to("##{identifier}", project_issue_url(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}"))
end end
end end
def reference_merge_request(identifier) def reference_merge_request(identifier)
if merge_request = @project.merge_requests.where(id: identifier).first if merge_request = @project.merge_requests.where(id: identifier).first
link_to("!#{identifier}", project_merge_request_path(@project, merge_request), html_options.merge(title: "Merge Request: #{merge_request.title}", class: "gfm gfm-merge_request #{html_options[:class]}")) link_to("!#{identifier}", project_merge_request_url(@project, merge_request), html_options.merge(title: "Merge Request: #{merge_request.title}", class: "gfm gfm-merge_request #{html_options[:class]}"))
end end
end end
def reference_snippet(identifier) def reference_snippet(identifier)
if snippet = @project.snippets.where(id: identifier).first if snippet = @project.snippets.where(id: identifier).first
link_to("$#{identifier}", project_snippet_path(@project, snippet), html_options.merge(title: "Snippet: #{snippet.title}", class: "gfm gfm-snippet #{html_options[:class]}")) link_to("$#{identifier}", project_snippet_url(@project, snippet), html_options.merge(title: "Snippet: #{snippet.title}", class: "gfm gfm-snippet #{html_options[:class]}"))
end end
end end
def reference_commit(identifier) def reference_commit(identifier)
if @project.valid_repo? && commit = @project.repository.commit(identifier) if @project.valid_repo? && commit = @project.repository.commit(identifier)
link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) link_to(identifier, project_commit_url(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}"))
end end
end end
end end
......
...@@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do ...@@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do
groups[0].should match(/This should finally fix $/) groups[0].should match(/This should finally fix $/)
# First issue link # First issue link
groups[1].should match(/href="#{project_issue_path(project, issues[0])}"/) groups[1].should match(/href="#{project_issue_url(project, issues[0])}"/)
groups[1].should match(/##{issues[0].id}$/) groups[1].should match(/##{issues[0].id}$/)
# Internal commit link # Internal commit link
...@@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do ...@@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do
groups[2].should match(/ and /) groups[2].should match(/ and /)
# Second issue link # Second issue link
groups[3].should match(/href="#{project_issue_path(project, issues[1])}"/) groups[3].should match(/href="#{project_issue_url(project, issues[1])}"/)
groups[3].should match(/##{issues[1].id}$/) groups[3].should match(/##{issues[1].id}$/)
# Trailing commit link # Trailing commit link
...@@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do ...@@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do
it "should leave inline code untouched" do it "should leave inline code untouched" do
markdown("\nDon't use `$#{snippet.id}` here.\n").should == "<p>Don&#39;t use <code>$#{snippet.id}</code> here.</p>\n" markdown("\nDon't use `$#{snippet.id}` here.\n").should == "<p>Don&#39;t use <code>$#{snippet.id}</code> here.</p>\n"
end end
it "should generate absolute urls for refs" do
markdown("##{issue.id}").should include(project_issue_url(project, issue))
end
end end
end end
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