Make a system comment when issue milestone changed

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-06-10 12:25:43 +03:00
parent f055bad513
commit 7edf65d1ee
No known key found for this signature in database
GPG Key ID: 627C5F589F467F17
3 changed files with 24 additions and 0 deletions

View File

@ -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}_"

View File

@ -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

View File

@ -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)