Commit c6707291 authored by Luke Picciau's avatar Luke Picciau Committed by Sean McGivern

Change system notes to use relative urls

parent b02c2583
...@@ -25,7 +25,7 @@ module SystemNoteService ...@@ -25,7 +25,7 @@ module SystemNoteService
text_parts = ["added #{commits_text}"] text_parts = ["added #{commits_text}"]
text_parts << commits_list(noteable, new_commits, existing_commits, oldrev) text_parts << commits_list(noteable, new_commits, existing_commits, oldrev)
text_parts << "[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})" text_parts << "[Compare with previous version](#{diff_comparison_path(noteable, project, oldrev)})"
body = text_parts.join("\n\n") body = text_parts.join("\n\n")
...@@ -41,7 +41,7 @@ module SystemNoteService ...@@ -41,7 +41,7 @@ module SystemNoteService
# #
# Returns the created Note object # Returns the created Note object
def tag_commit(noteable, project, author, tag_name) def tag_commit(noteable, project, author, tag_name)
link = url_helpers.project_tag_url(project, id: tag_name) link = url_helpers.project_tag_path(project, id: tag_name)
body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})" body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
create_note(NoteSummary.new(noteable, project, author, body, action: 'tag')) create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))
...@@ -272,7 +272,7 @@ module SystemNoteService ...@@ -272,7 +272,7 @@ module SystemNoteService
text_parts = ["changed this line in"] text_parts = ["changed this line in"]
if version_params = merge_request.version_params_for(diff_refs) if version_params = merge_request.version_params_for(diff_refs)
line_code = change_position.line_code(project.repository) line_code = change_position.line_code(project.repository)
url = url_helpers.diffs_project_merge_request_url(project, merge_request, version_params.merge(anchor: line_code)) url = url_helpers.diffs_project_merge_request_path(project, merge_request, version_params.merge(anchor: line_code))
text_parts << "[version #{version_index} of the diff](#{url})" text_parts << "[version #{version_index} of the diff](#{url})"
else else
...@@ -405,7 +405,7 @@ module SystemNoteService ...@@ -405,7 +405,7 @@ module SystemNoteService
# #
# "created branch `201-issue-branch-button`" # "created branch `201-issue-branch-button`"
def new_issue_branch(issue, project, author, branch) def new_issue_branch(issue, project, author, branch)
link = url_helpers.project_compare_url(project, from: project.default_branch, to: branch) link = url_helpers.project_compare_path(project, from: project.default_branch, to: branch)
body = "created branch [`#{branch}`](#{link}) to address this issue" body = "created branch [`#{branch}`](#{link}) to address this issue"
...@@ -668,10 +668,10 @@ module SystemNoteService ...@@ -668,10 +668,10 @@ module SystemNoteService
@url_helpers ||= Gitlab::Routing.url_helpers @url_helpers ||= Gitlab::Routing.url_helpers
end end
def diff_comparison_url(merge_request, project, oldrev) def diff_comparison_path(merge_request, project, oldrev)
diff_id = merge_request.merge_request_diff.id diff_id = merge_request.merge_request_diff.id
url_helpers.diffs_project_merge_request_url( url_helpers.diffs_project_merge_request_path(
project, project,
merge_request, merge_request,
diff_id: diff_id, diff_id: diff_id,
......
---
title: Change links in system notes to use relative paths
merge_request: 28588
author: Luke Picciau
type: fixed
...@@ -132,7 +132,7 @@ describe SystemNoteService do ...@@ -132,7 +132,7 @@ describe SystemNoteService do
end end
it 'sets the note text' do it 'sets the note text' do
link = "http://localhost/#{project.full_path}/-/tags/#{tag_name}" link = "/#{project.full_path}/-/tags/#{tag_name}"
expect(subject.note).to eq "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})" expect(subject.note).to eq "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
end end
...@@ -1139,7 +1139,7 @@ describe SystemNoteService do ...@@ -1139,7 +1139,7 @@ describe SystemNoteService do
diff_id = merge_request.merge_request_diff.id diff_id = merge_request.merge_request_diff.id
line_code = change_position.line_code(project.repository) line_code = change_position.line_code(project.repository)
expect(subject.note).to include(diffs_project_merge_request_url(project, merge_request, diff_id: diff_id, anchor: line_code)) expect(subject.note).to include(diffs_project_merge_request_path(project, merge_request, diff_id: diff_id, anchor: line_code))
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