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,31 +147,31 @@ module Gitlab | ||
147 | 147 | ||
148 | def reference_user(identifier) | 148 | def reference_user(identifier) |
149 | if member = @project.users_projects.joins(:user).where(users: { username: identifier }).first | 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 | end | 151 | end |
152 | end | 152 | end |
153 | 153 | ||
154 | def reference_issue(identifier) | 154 | def reference_issue(identifier) |
155 | if issue = @project.issues.where(id: identifier).first | 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 | end | 157 | end |
158 | end | 158 | end |
159 | 159 | ||
160 | def reference_merge_request(identifier) | 160 | def reference_merge_request(identifier) |
161 | if merge_request = @project.merge_requests.where(id: identifier).first | 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 | end | 163 | end |
164 | end | 164 | end |
165 | 165 | ||
166 | def reference_snippet(identifier) | 166 | def reference_snippet(identifier) |
167 | if snippet = @project.snippets.where(id: identifier).first | 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 | end | 169 | end |
170 | end | 170 | end |
171 | 171 | ||
172 | def reference_commit(identifier) | 172 | def reference_commit(identifier) |
173 | if @project.valid_repo? && commit = @project.repository.commit(identifier) | 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 | end | 175 | end |
176 | end | 176 | end |
177 | end | 177 | end |
spec/helpers/gitlab_markdown_helper_spec.rb
@@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do | @@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do | ||
272 | groups[0].should match(/This should finally fix $/) | 272 | groups[0].should match(/This should finally fix $/) |
273 | 273 | ||
274 | # First issue link | 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 | groups[1].should match(/##{issues[0].id}$/) | 276 | groups[1].should match(/##{issues[0].id}$/) |
277 | 277 | ||
278 | # Internal commit link | 278 | # Internal commit link |
@@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do | @@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do | ||
280 | groups[2].should match(/ and /) | 280 | groups[2].should match(/ and /) |
281 | 281 | ||
282 | # Second issue link | 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 | groups[3].should match(/##{issues[1].id}$/) | 284 | groups[3].should match(/##{issues[1].id}$/) |
285 | 285 | ||
286 | # Trailing commit link | 286 | # Trailing commit link |
@@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do | @@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do | ||
339 | it "should leave inline code untouched" do | 339 | it "should leave inline code untouched" do |
340 | markdown("\nDon't use `$#{snippet.id}` here.\n").should == "<p>Don't use <code>$#{snippet.id}</code> here.</p>\n" | 340 | markdown("\nDon't use `$#{snippet.id}` here.\n").should == "<p>Don't use <code>$#{snippet.id}</code> here.</p>\n" |
341 | end | 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 | end | 346 | end |
343 | end | 347 | end |