Use Urls for references in GFM
This commit is contained in:
parent
640d51f4b6
commit
7635afd0c4
|
@ -147,31 +147,31 @@ module Gitlab
|
|||
|
||||
def reference_user(identifier)
|
||||
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
|
||||
|
||||
def reference_issue(identifier)
|
||||
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
|
||||
|
||||
def reference_merge_request(identifier)
|
||||
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
|
||||
|
||||
def reference_snippet(identifier)
|
||||
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
|
||||
|
||||
def reference_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
|
||||
|
|
|
@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do
|
|||
groups[0].should match(/This should finally fix $/)
|
||||
|
||||
# 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}$/)
|
||||
|
||||
# Internal commit link
|
||||
|
@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do
|
|||
groups[2].should match(/ and /)
|
||||
|
||||
# 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}$/)
|
||||
|
||||
# Trailing commit link
|
||||
|
@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do
|
|||
it "should leave inline code untouched" do
|
||||
markdown("\nDon't use `$#{snippet.id}` here.\n").should == "<p>Don't use <code>$#{snippet.id}</code> here.</p>\n"
|
||||
end
|
||||
|
||||
it "should generate absolute urls for refs" do
|
||||
markdown("##{issue.id}").should include(project_issue_url(project, issue))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue