summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-10 12:25:43 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-10 12:25:43 +0300
commit7edf65d1ee9e65e5d5d2bde573936715b46e250d (patch)
treeba9b081f456b1749a4845f2a0ec907202dcf6c54 /app
parentf055bad5135c8c3934daf16f8d9400f9a23b8960 (diff)
downloadgitlab-ce-7edf65d1ee9e65e5d5d2bde573936715b46e250d.tar.gz
Make a system comment when issue milestone changed
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app')
-rw-r--r--app/models/note.rb16
-rw-r--r--app/services/issues/base_service.rb4
-rw-r--r--app/services/issues/update_service.rb4
3 files changed, 24 insertions, 0 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 278c957af0e..dc8b968c3d2 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -90,6 +90,22 @@ class Note < ActiveRecord::Base
create(note_options, without_protection: true)
end
+ def create_milestone_change_note(noteable, project, author, milestone)
+ body = if milestone.nil?
+ '_Milestone removed_'
+ else
+ "_Milestone changed to #{milestone.title}_"
+ end
+
+ create({
+ noteable: noteable,
+ project: project,
+ author: author,
+ note: body,
+ system: true
+ }, without_protection: true)
+ end
+
def create_assignee_change_note(noteable, project, author, assignee)
body = assignee.nil? ? '_Assignee removed_' : "_Reassigned to @#{assignee.username}_"
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index 2e1e1f7e0f0..eac774210ae 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -10,5 +10,9 @@ module Issues
def execute_hooks(issue)
issue.project.execute_hooks(issue.to_hook_data, :issue_hooks)
end
+
+ def create_milestone_note(issue)
+ Note.create_milestone_change_note(issue, issue.project, current_user, issue.milestone)
+ end
end
end
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index b562c401fd4..f69370beddd 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -13,6 +13,10 @@ module Issues
if params.present? && issue.update_attributes(params)
issue.reset_events_cache
+ if issue.previous_changes.include?('milestone_id')
+ create_milestone_note(issue)
+ end
+
if issue.previous_changes.include?('assignee_id')
notification_service.reassigned_issue(issue, current_user)
create_assignee_note(issue)