From 9f49b926d631008ccaa3edbbf5ca54b415047b32 Mon Sep 17 00:00:00 2001 From: Nick Oliver <github@pixnbits.org> Date: Mon, 6 Jan 2014 11:00:50 -0700 Subject: [PATCH] Issue Notes: record assignee changes in the comment timeline as proposed in http://feedback.gitlab.com/forums/176466-general/suggestions/5168130-record-assignee-changes-in-the-comment-timeline --- app/models/note.rb | 12 ++++++++++++ app/observers/issue_observer.rb | 1 + 2 files changed, 13 insertions(+) diff --git a/app/models/note.rb b/app/models/note.rb index 8284da8616f..0a9c6552781 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -68,6 +68,18 @@ class Note < ActiveRecord::Base }, without_protection: true) end + def self.create_assignee_change_note(noteable, project, author, assignee, source) + body = "_Reassigned to @#{assignee.username}_" + + create({ + noteable: noteable, + project: project, + author: author, + note: body, + system: true + }, without_protection: true) + end + # +noteable+ was referenced from +mentioner+, by including GFM in either +mentioner+'s description or an associated Note. # Create a system Note associated with +noteable+ with a GFM back-reference to +mentioner+. def self.create_cross_reference_note(noteable, mentioner, author, project) diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb index b150e39e239..77a99388842 100644 --- a/app/observers/issue_observer.rb +++ b/app/observers/issue_observer.rb @@ -18,6 +18,7 @@ class IssueObserver < BaseObserver def after_update(issue) if issue.is_being_reassigned? notification.reassigned_issue(issue, current_user) + Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee, current_commit) end issue.notice_added_references(issue.project, current_user) -- GitLab