Commit 323596f6 authored by blackst0ne's avatar blackst0ne

Add system note on description change of issue/merge request

parent 4faa65d8
module SystemNoteHelper module SystemNoteHelper
ICON_NAMES_BY_ACTION = { ICON_NAMES_BY_ACTION = {
'commit' => 'icon_commit', 'commit' => 'icon_commit',
'description' => 'icon_edit',
'merge' => 'icon_merge', 'merge' => 'icon_merge',
'merged' => 'icon_merged', 'merged' => 'icon_merged',
'opened' => 'icon_status_open', 'opened' => 'icon_status_open',
......
class SystemNoteMetadata < ActiveRecord::Base class SystemNoteMetadata < ActiveRecord::Base
ICON_TYPES = %w[ ICON_TYPES = %w[
commit merge confidential visible label assignee cross_reference commit description merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved opened closed merged title time_tracking branch milestone discussion task moved opened closed merged
].freeze ].freeze
......
...@@ -24,6 +24,10 @@ class IssuableBaseService < BaseService ...@@ -24,6 +24,10 @@ class IssuableBaseService < BaseService
issuable, issuable.project, current_user, old_title) issuable, issuable.project, current_user, old_title)
end end
def create_description_change_note(issuable)
SystemNoteService.change_description(issuable, issuable.project, current_user)
end
def create_branch_change_note(issuable, branch_type, old_branch, new_branch) def create_branch_change_note(issuable, branch_type, old_branch, new_branch)
SystemNoteService.change_branch( SystemNoteService.change_branch(
issuable, issuable.project, current_user, branch_type, issuable, issuable.project, current_user, branch_type,
...@@ -289,6 +293,10 @@ class IssuableBaseService < BaseService ...@@ -289,6 +293,10 @@ class IssuableBaseService < BaseService
create_title_change_note(issuable, issuable.previous_changes['title'].first) create_title_change_note(issuable, issuable.previous_changes['title'].first)
end end
if issuable.previous_changes.include?('description')
create_description_change_note(issuable)
end
if issuable.previous_changes.include?('description') && issuable.tasks? if issuable.previous_changes.include?('description') && issuable.tasks?
create_task_status_note(issuable) create_task_status_note(issuable)
end end
......
...@@ -261,6 +261,23 @@ module SystemNoteService ...@@ -261,6 +261,23 @@ module SystemNoteService
create_note(NoteSummary.new(noteable, project, author, body, action: 'title')) create_note(NoteSummary.new(noteable, project, author, body, action: 'title'))
end end
# Called when the description of a Noteable is changed
#
# noteable - Noteable object that responds to `description`
# project - Project owning noteable
# author - User performing the change
#
# Example Note text:
#
# "changed the description"
#
# Returns the created Note object
def change_description(noteable, project, author)
body = "changed the description"
create_note(NoteSummary.new(noteable, project, author, body, action: 'description'))
end
# Called when the confidentiality changes # Called when the confidentiality changes
# #
# issue - Issue object # issue - Issue object
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
= markdown_field(@issue, :description) = markdown_field(@issue, :description)
%textarea.hidden.js-task-list-field %textarea.hidden.js-task-list-field
= @issue.description = @issue.description
= edited_time_ago_with_tooltip(@issue, placement: 'bottom', html_class: 'issue_edited_ago') = edited_time_ago_with_tooltip(@issue, placement: 'bottom', html_class: 'issue_edited_ago', include_author: true)
#merge-requests{ data: { url: referenced_merge_requests_namespace_project_issue_url(@project.namespace, @project, @issue) } } #merge-requests{ data: { url: referenced_merge_requests_namespace_project_issue_url(@project.namespace, @project, @issue) } }
// This element is filled in using JavaScript. // This element is filled in using JavaScript.
......
...@@ -10,4 +10,4 @@ ...@@ -10,4 +10,4 @@
%textarea.hidden.js-task-list-field %textarea.hidden.js-task-list-field
= @merge_request.description = @merge_request.description
= edited_time_ago_with_tooltip(@merge_request, placement: 'bottom') = edited_time_ago_with_tooltip(@merge_request, placement: 'bottom', include_author: true)
---
title: Add system note on description change of issue/merge request
merge_request: 10392
author: blackst0ne
...@@ -292,6 +292,20 @@ describe SystemNoteService, services: true do ...@@ -292,6 +292,20 @@ describe SystemNoteService, services: true do
end end
end end
describe '.change_description' do
subject { described_class.change_description(noteable, project, author) }
context 'when noteable responds to `description`' do
it_behaves_like 'a system note' do
let(:action) { 'description' }
end
it 'sets the note text' do
expect(subject.note).to eq 'changed the description'
end
end
end
describe '.change_issue_confidentiality' do describe '.change_issue_confidentiality' do
subject { described_class.change_issue_confidentiality(noteable, project, author) } subject { described_class.change_issue_confidentiality(noteable, project, author) }
......
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