diff options
author | Rémy Coutable <remy@rymai.me> | 2018-12-18 10:08:44 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-12-18 10:08:44 +0000 |
commit | f3d80159fcfa3c1e4d5a6d3c747ef89293288621 (patch) | |
tree | 327580fd572b17e6a6f954cf95083deaeec46b5c /app/services | |
parent | c516c801c5530555863b9ff52ca1f01f63c00a19 (diff) | |
parent | 9d1090d49b3077a4a785d2f624e60686d0a863e3 (diff) | |
download | gitlab-ce-f3d80159fcfa3c1e4d5a6d3c747ef89293288621.tar.gz |
Merge branch '51485-new-issue-labels-note' into 'master'
Run CommonSystemNotesService on issuable create
Closes #51485
See merge request gitlab-org/gitlab-ce!23859
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/issuable/common_system_notes_service.rb | 21 | ||||
-rw-r--r-- | app/services/issuable_base_service.rb | 6 |
2 files changed, 17 insertions, 10 deletions
diff --git a/app/services/issuable/common_system_notes_service.rb b/app/services/issuable/common_system_notes_service.rb index 765de9c66b0..885e14bba8f 100644 --- a/app/services/issuable/common_system_notes_service.rb +++ b/app/services/issuable/common_system_notes_service.rb @@ -4,20 +4,23 @@ module Issuable class CommonSystemNotesService < ::BaseService attr_reader :issuable - def execute(issuable, old_labels) + def execute(issuable, old_labels: [], is_update: true) @issuable = issuable - if issuable.previous_changes.include?('title') - create_title_change_note(issuable.previous_changes['title'].first) - end + if is_update + if issuable.previous_changes.include?('title') + create_title_change_note(issuable.previous_changes['title'].first) + end - handle_description_change_note + handle_description_change_note + + handle_time_tracking_note if issuable.is_a?(TimeTrackable) + create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked') + end - handle_time_tracking_note if issuable.is_a?(TimeTrackable) - 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') + create_milestone_note if issuable.previous_changes.include?('milestone_id') + create_labels_note(old_labels) if issuable.labels != old_labels end private diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index e32e262ac31..c7e7bb55e4b 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -152,6 +152,10 @@ class IssuableBaseService < BaseService before_create(issuable) if issuable.save + ActiveRecord::Base.no_touching do + Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, is_update: false) + end + after_create(issuable) execute_hooks(issuable) invalidate_cache_counts(issuable, users: issuable.assignees) @@ -207,7 +211,7 @@ class IssuableBaseService < BaseService if issuable.with_transaction_returning_status { issuable.save } # We do not touch as it will affect a update on updated_at field ActiveRecord::Base.no_touching do - Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_associations[:labels]) + Issuable::CommonSystemNotesService.new(project, current_user).execute(issuable, old_labels: old_associations[:labels]) end handle_changes(issuable, old_associations: old_associations) |