Commit ac0358b5 authored by Ruben Davila's avatar Ruben Davila

Add system note when time estimate for Issue/MergeRequest is changed.

parent 88a630c1
......@@ -36,6 +36,11 @@ class IssuableBaseService < BaseService
end
end
def create_time_estimate_note(issuable)
SystemNoteService.change_time_estimate(
issuable, issuable.project, current_user, issuable.time_estimate)
end
def filter_params(issuable_ability_name = :issue)
filter_assignee
filter_milestone
......
......@@ -28,6 +28,10 @@ module Issues
create_confidentiality_note(issue)
end
if issue.previous_changes.include?('time_estimate')
create_time_estimate_note(issue)
end
added_labels = issue.labels - old_labels
if added_labels.present?
notification_service.relabeled_issue(issue, added_labels, current_user)
......
......@@ -111,6 +111,26 @@ module SystemNoteService
create_note(noteable: noteable, project: project, author: author, note: body)
end
# Called when the estimated time of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
# milestone - Milestone being assigned, or nil
#
# Example Note text:
#
# "Changed estimate of this issue to 3d 5h"
#
# Returns the created Note object
def change_time_estimate(noteable, project, author, time_estimate)
parsed_time = ChronicDuration.output(time_estimate, format: :short)
body = "Changed estimate of this #{noteable.to_ability_name} to #{parsed_time}"
create_note(noteable: noteable, project: project, author: author, note: body)
end
# Called when the status of a Noteable is changed
#
# noteable - Noteable object
......
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