Commit 7edf65d1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Make a system comment when issue milestone changed

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f055bad5
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment