diff options
author | Eva Kadlecová <evka.kadl@gmail.com> | 2018-09-09 21:08:21 +0300 |
---|---|---|
committer | Eva Kadlecová <evka.kadl@gmail.com> | 2018-09-09 22:43:37 +0300 |
commit | 997dda50f4567cf218df80c0fd5fe64afb18bf2e (patch) | |
tree | abd34c4daf30c0cd03fd6d39b0ea0520b39baf08 /app/services | |
parent | 120ce02e5e7e72654cb42edddc25ff3b057ec136 (diff) |
Add system note when due date is changed
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/issuable/common_system_notes_service.rb | 5 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/app/services/issuable/common_system_notes_service.rb b/app/services/issuable/common_system_notes_service.rb index 028b350ca07..b1efebaf388 100644 --- a/app/services/issuable/common_system_notes_service.rb +++ b/app/services/issuable/common_system_notes_service.rb @@ -17,6 +17,7 @@ module Issuable create_labels_note(old_labels) if issuable.labels != old_labels create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked') create_milestone_note if issuable.previous_changes.include?('milestone_id') + create_due_date_note if issuable.previous_changes.include?('due_date') end private @@ -88,6 +89,10 @@ module Issuable SystemNoteService.change_milestone(issuable, issuable.project, current_user, issuable.milestone) end + def create_due_date_note + SystemNoteService.change_due_date(issuable, issuable.project, current_user, issuable.due_date) + end + def create_discussion_lock_note SystemNoteService.discussion_lock(issuable, current_user) end diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index dda89830179..ba6709c010b 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -160,6 +160,26 @@ module SystemNoteService create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone')) end + # Called when the due_date of a Noteable is changed + # + # noteable - Noteable object + # project - Project owning noteable + # author - User performing the change + # due_date - Due date being assigned, or nil + # + # Example Note text: + # + # "removed due date" + # + # "changed due date to September 20, 2018" + # + # Returns the created Note object + def change_due_date(noteable, project, author, due_date) + body = due_date ? "changed due date to #{due_date.to_s(:long)}" : 'removed due date' + + create_note(NoteSummary.new(noteable, project, author, body, action: 'due_date')) + end + # Called when the estimated time of a Noteable is changed # # noteable - Noteable object |