Commit 7edf65d1ee9e65e5d5d2bde573936715b46e250d
1 parent
f055bad5
Exists in
spb-stable
and in
2 other branches
Make a system comment when issue milestone changed
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
24 additions
and
0 deletions
Show diff stats
app/models/note.rb
... | ... | @@ -90,6 +90,22 @@ class Note < ActiveRecord::Base |
90 | 90 | create(note_options, without_protection: true) |
91 | 91 | end |
92 | 92 | |
93 | + def create_milestone_change_note(noteable, project, author, milestone) | |
94 | + body = if milestone.nil? | |
95 | + '_Milestone removed_' | |
96 | + else | |
97 | + "_Milestone changed to #{milestone.title}_" | |
98 | + end | |
99 | + | |
100 | + create({ | |
101 | + noteable: noteable, | |
102 | + project: project, | |
103 | + author: author, | |
104 | + note: body, | |
105 | + system: true | |
106 | + }, without_protection: true) | |
107 | + end | |
108 | + | |
93 | 109 | def create_assignee_change_note(noteable, project, author, assignee) |
94 | 110 | body = assignee.nil? ? '_Assignee removed_' : "_Reassigned to @#{assignee.username}_" |
95 | 111 | ... | ... |
app/services/issues/base_service.rb
... | ... | @@ -10,5 +10,9 @@ module Issues |
10 | 10 | def execute_hooks(issue) |
11 | 11 | issue.project.execute_hooks(issue.to_hook_data, :issue_hooks) |
12 | 12 | end |
13 | + | |
14 | + def create_milestone_note(issue) | |
15 | + Note.create_milestone_change_note(issue, issue.project, current_user, issue.milestone) | |
16 | + end | |
13 | 17 | end |
14 | 18 | end | ... | ... |
app/services/issues/update_service.rb
... | ... | @@ -13,6 +13,10 @@ module Issues |
13 | 13 | if params.present? && issue.update_attributes(params) |
14 | 14 | issue.reset_events_cache |
15 | 15 | |
16 | + if issue.previous_changes.include?('milestone_id') | |
17 | + create_milestone_note(issue) | |
18 | + end | |
19 | + | |
16 | 20 | if issue.previous_changes.include?('assignee_id') |
17 | 21 | notification_service.reassigned_issue(issue, current_user) |
18 | 22 | create_assignee_note(issue) | ... | ... |