summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2017-04-29 10:54:37 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2017-05-04 12:58:41 +1100
commit323596f68efe95b479a0dc29832b8033a1eddef0 (patch)
treecbf2190f46a6df26f694ae67ce1c2b0f826a71c8
parent4faa65d8381f3e1e45bdf3a9bc9785b588891b66 (diff)
downloadgitlab-ce-323596f68efe95b479a0dc29832b8033a1eddef0.tar.gz
Add system note on description change of issue/merge request
-rw-r--r--app/helpers/system_note_helper.rb1
-rw-r--r--app/models/system_note_metadata.rb2
-rw-r--r--app/services/issuable_base_service.rb8
-rw-r--r--app/services/system_note_service.rb17
-rw-r--r--app/views/projects/issues/show.html.haml2
-rw-r--r--app/views/projects/merge_requests/show/_mr_box.html.haml2
-rw-r--r--changelogs/unreleased/add_system_note_for_editing_issuable.yml4
-rw-r--r--spec/services/system_note_service_spec.rb14
8 files changed, 47 insertions, 3 deletions
diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb
index 1ea60e39386..d889d141101 100644
--- a/app/helpers/system_note_helper.rb
+++ b/app/helpers/system_note_helper.rb
@@ -1,6 +1,7 @@
module SystemNoteHelper
ICON_NAMES_BY_ACTION = {
'commit' => 'icon_commit',
+ 'description' => 'icon_edit',
'merge' => 'icon_merge',
'merged' => 'icon_merged',
'opened' => 'icon_status_open',
diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb
index 1e6fc837a75..b44f4fe000c 100644
--- a/app/models/system_note_metadata.rb
+++ b/app/models/system_note_metadata.rb
@@ -1,6 +1,6 @@
class SystemNoteMetadata < ActiveRecord::Base
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
].freeze
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index b071a398481..7072d78b28d 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -24,6 +24,10 @@ class IssuableBaseService < BaseService
issuable, issuable.project, current_user, old_title)
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)
SystemNoteService.change_branch(
issuable, issuable.project, current_user, branch_type,
@@ -289,6 +293,10 @@ class IssuableBaseService < BaseService
create_title_change_note(issuable, issuable.previous_changes['title'].first)
end
+ if issuable.previous_changes.include?('description')
+ create_description_change_note(issuable)
+ end
+
if issuable.previous_changes.include?('description') && issuable.tasks?
create_task_status_note(issuable)
end
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index c9e25c7aaa2..82694305a92 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -261,6 +261,23 @@ module SystemNoteService
create_note(NoteSummary.new(noteable, project, author, body, action: 'title'))
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
#
# issue - Issue object
diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml
index 2a871966aa8..9bddc3ac44d 100644
--- a/app/views/projects/issues/show.html.haml
+++ b/app/views/projects/issues/show.html.haml
@@ -61,7 +61,7 @@
= markdown_field(@issue, :description)
%textarea.hidden.js-task-list-field
= @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) } }
// This element is filled in using JavaScript.
diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml
index 8a390cf8700..3b2cbb12a85 100644
--- a/app/views/projects/merge_requests/show/_mr_box.html.haml
+++ b/app/views/projects/merge_requests/show/_mr_box.html.haml
@@ -10,4 +10,4 @@
%textarea.hidden.js-task-list-field
= @merge_request.description
- = edited_time_ago_with_tooltip(@merge_request, placement: 'bottom')
+ = edited_time_ago_with_tooltip(@merge_request, placement: 'bottom', include_author: true)
diff --git a/changelogs/unreleased/add_system_note_for_editing_issuable.yml b/changelogs/unreleased/add_system_note_for_editing_issuable.yml
new file mode 100644
index 00000000000..3cbc7f91bf0
--- /dev/null
+++ b/changelogs/unreleased/add_system_note_for_editing_issuable.yml
@@ -0,0 +1,4 @@
+---
+title: Add system note on description change of issue/merge request
+merge_request: 10392
+author: blackst0ne
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 75d7caf2508..5e85c3c1621 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -292,6 +292,20 @@ describe SystemNoteService, services: true do
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
subject { described_class.change_issue_confidentiality(noteable, project, author) }