summaryrefslogtreecommitdiff
path: root/app/services/system_note_service.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-02-16 11:47:00 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-03-17 07:39:15 +0100
commit9882802a8b70e998ff6850a3d096b3b52730ab85 (patch)
tree69403cc0e54d37c8cafcf978f023f23ad351abf9 /app/services/system_note_service.rb
parent69b89d4ec8f9788dc11f30cdf1f782d316ab252c (diff)
downloadgitlab-ce-9882802a8b70e998ff6850a3d096b3b52730ab85.tar.gz
Improve system notes that are added when issue is moved
Diffstat (limited to 'app/services/system_note_service.rb')
-rw-r--r--app/services/system_note_service.rb25
1 files changed, 16 insertions, 9 deletions
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 95379d260f1..a8d6555dec3 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -3,6 +3,7 @@
# Used for creating system notes (e.g., when a user references a merge request
# from an issue, an issue's assignee changes, an issue is closed, etc.)
class SystemNoteService
+ extend GitlabMarkdownHelper
# Called when commits are added to a Merge Request
#
# noteable - Noteable object
@@ -388,20 +389,26 @@ class SystemNoteService
create_note(noteable: noteable, project: project, author: author, note: body)
end
- # Called when issue has been moved to another project
+ # Called when noteable has been moved to another project
#
- # issue - Issue that has been moved to another project
- # project_from - Source project of the issue
- # project_to - Destination project for the issue
- # author - User performing the move
+ # direction - symbol, :to or :from
+ # noteable - Noteable object
+ # noteable_ref - Referenced noteable
+ # author - User performing the move
#
# Example Note text:
#
- # "This issue has been moved to SomeNamespace / SomeProject"
+ # "Moved to project_new/#11"
#
# Returns the created Note object
- def self.issue_moved_to_another_project(issue, project_from, project_to, author)
- body = "This issue has been moved to #{project_to.to_reference} by #{author.to_reference}"
- create_note(noteable: issue, project: project_from, author: author, note: body)
+ def self.noteable_moved(direction, noteable, project, noteable_ref, author)
+ unless [:to, :from].include?(direction)
+ raise StandardError, "Invalid direction `#{direction}`"
+ end
+
+ cross_reference = cross_project_reference(noteable_ref.project, noteable_ref)
+
+ body = "Moved #{direction} #{cross_reference}"
+ create_note(noteable: noteable, project: project, author: author, note: body)
end
end