Commit 7635afd0c4872e2552413b17b1a63bae76e62e45
1 parent
640d51f4
Exists in
master
and in
4 other branches
Use Urls for references in GFM
Showing
2 changed files
with
11 additions
and
7 deletions
Show diff stats
lib/gitlab/markdown.rb
... | ... | @@ -147,31 +147,31 @@ module Gitlab |
147 | 147 | |
148 | 148 | def reference_user(identifier) |
149 | 149 | if member = @project.users_projects.joins(:user).where(users: { username: identifier }).first |
150 | - link_to("@#{identifier}", project_team_member_path(@project, member), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member | |
150 | + link_to("@#{identifier}", project_team_member_url(@project, member), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member | |
151 | 151 | end |
152 | 152 | end |
153 | 153 | |
154 | 154 | def reference_issue(identifier) |
155 | 155 | if issue = @project.issues.where(id: identifier).first |
156 | - link_to("##{identifier}", project_issue_path(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) | |
156 | + link_to("##{identifier}", project_issue_url(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) | |
157 | 157 | end |
158 | 158 | end |
159 | 159 | |
160 | 160 | def reference_merge_request(identifier) |
161 | 161 | if merge_request = @project.merge_requests.where(id: identifier).first |
162 | - 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]}")) | |
162 | + 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]}")) | |
163 | 163 | end |
164 | 164 | end |
165 | 165 | |
166 | 166 | def reference_snippet(identifier) |
167 | 167 | if snippet = @project.snippets.where(id: identifier).first |
168 | - link_to("$#{identifier}", project_snippet_path(@project, snippet), html_options.merge(title: "Snippet: #{snippet.title}", class: "gfm gfm-snippet #{html_options[:class]}")) | |
168 | + link_to("$#{identifier}", project_snippet_url(@project, snippet), html_options.merge(title: "Snippet: #{snippet.title}", class: "gfm gfm-snippet #{html_options[:class]}")) | |
169 | 169 | end |
170 | 170 | end |
171 | 171 | |
172 | 172 | def reference_commit(identifier) |
173 | 173 | if @project.valid_repo? && commit = @project.repository.commit(identifier) |
174 | - link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) | |
174 | + link_to(identifier, project_commit_url(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) | |
175 | 175 | end |
176 | 176 | end |
177 | 177 | end | ... | ... |
spec/helpers/gitlab_markdown_helper_spec.rb
... | ... | @@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do |
272 | 272 | groups[0].should match(/This should finally fix $/) |
273 | 273 | |
274 | 274 | # First issue link |
275 | - groups[1].should match(/href="#{project_issue_path(project, issues[0])}"/) | |
275 | + groups[1].should match(/href="#{project_issue_url(project, issues[0])}"/) | |
276 | 276 | groups[1].should match(/##{issues[0].id}$/) |
277 | 277 | |
278 | 278 | # Internal commit link |
... | ... | @@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do |
280 | 280 | groups[2].should match(/ and /) |
281 | 281 | |
282 | 282 | # Second issue link |
283 | - groups[3].should match(/href="#{project_issue_path(project, issues[1])}"/) | |
283 | + groups[3].should match(/href="#{project_issue_url(project, issues[1])}"/) | |
284 | 284 | groups[3].should match(/##{issues[1].id}$/) |
285 | 285 | |
286 | 286 | # Trailing commit link |
... | ... | @@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do |
339 | 339 | it "should leave inline code untouched" do |
340 | 340 | markdown("\nDon't use `$#{snippet.id}` here.\n").should == "<p>Don't use <code>$#{snippet.id}</code> here.</p>\n" |
341 | 341 | end |
342 | + | |
343 | + it "should generate absolute urls for refs" do | |
344 | + markdown("##{issue.id}").should include(project_issue_url(project, issue)) | |
345 | + end | |
342 | 346 | end |
343 | 347 | end | ... | ... |