summaryrefslogtreecommitdiff
path: root/app/services/system_note_service.rb
diff options
context:
space:
mode:
authorMatthew Dodds <matthewrusselldodds@gmail.com>2016-09-30 11:00:03 -0400
committerMatthew Dodds <matthewrusselldodds@gmail.com>2016-09-30 11:00:03 -0400
commit0c0b6f438ee5ac12f9975fb1c3b1dc93f6447015 (patch)
tree5cb80e277d25071a45628b0b91342f13be94b38f /app/services/system_note_service.rb
parentec82cecf3c54cb2cd1ab7b72f77e787be1bf1264 (diff)
downloadgitlab-ce-0c0b6f438ee5ac12f9975fb1c3b1dc93f6447015.tar.gz
Refactor url_helpers for system note service and remove duplication of logic in spec
Diffstat (limited to 'app/services/system_note_service.rb')
-rw-r--r--app/services/system_note_service.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 8da1af67ee6..5ccaa5275b7 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -21,10 +21,10 @@ module SystemNoteService
total_count = new_commits.length + existing_commits.length
commits_text = "#{total_count} commit".pluralize(total_count)
- body = "[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})\n\n"
- body << "Added #{commits_text}:\n\n"
+ body = "Added #{commits_text}:\n\n"
body << existing_commit_summary(noteable, existing_commits, oldrev)
body << new_commit_summary(new_commits).join("\n")
+ body << "\n\n[Compare with previous version](#{diff_comparison_url(noteable, project, oldrev)})"
create_note(noteable: noteable, project: project, author: author, note: body)
end
@@ -255,8 +255,7 @@ module SystemNoteService
#
# "Started branch `201-issue-branch-button`"
def new_issue_branch(issue, project, author, branch)
- h = Gitlab::Routing.url_helpers
- link = h.namespace_project_compare_url(project.namespace, project, from: project.default_branch, to: branch)
+ link = url_helpers.namespace_project_compare_url(project.namespace, project, from: project.default_branch, to: branch)
body = "Started branch [`#{branch}`](#{link})"
create_note(noteable: issue, project: project, author: author, note: body)
@@ -468,10 +467,14 @@ module SystemNoteService
Rack::Utils.escape_html(text)
end
+ def url_helpers
+ @url_helpers ||= Gitlab::Routing.url_helpers
+ end
+
def diff_comparison_url(merge_request, project, oldrev)
diff_id = merge_request.merge_request_diff.id
- Gitlab::Routing.url_helpers.diffs_namespace_project_merge_request_url(
+ url_helpers.diffs_namespace_project_merge_request_url(
project.namespace,
project,
merge_request.iid,