Make a system comment when issue milestone changed
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
f055bad513
commit
7edf65d1ee
|
@ -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}_"
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue