diff options
author | Rubén Dávila <ruben@gitlab.com> | 2015-11-20 18:36:12 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2015-11-20 18:36:12 +0300 |
commit | fc18e96db38f5d5ab5e102fe630682f6779203ba (patch) | |
tree | edb3c23d5185643ee04cb558cf63ce68dc4487fc /app | |
parent | 97afb84b310cfdaa9305e8b79fc00bdbb866bbca (diff) |
Refactor creation of system notes for Issue/MR labels. #2296
Diffstat (limited to 'app')
-rw-r--r-- | app/services/issuable_base_service.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 19055fb67ff..2556f06e2d3 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -53,15 +53,7 @@ class IssuableBaseService < BaseService if params.present? && issuable.update_attributes(params.merge(updated_by: current_user)) issuable.reset_events_cache - - if issuable.labels != old_labels - create_labels_note( - issuable, - issuable.labels - old_labels, - old_labels - issuable.labels) - end - - handle_common_system_notes(issuable) + handle_common_system_notes(issuable, old_labels: old_labels) handle_changes(issuable) issuable.create_new_cross_references!(current_user) execute_hooks(issuable, 'update') @@ -79,7 +71,7 @@ class IssuableBaseService < BaseService end end - def handle_common_system_notes(issuable) + def handle_common_system_notes(issuable, options = {}) if issuable.previous_changes.include?('title') create_title_change_note(issuable, issuable.previous_changes['title'].first) end @@ -87,5 +79,10 @@ class IssuableBaseService < BaseService if issuable.previous_changes.include?('description') && issuable.tasks? create_task_status_note(issuable) end + + old_labels = options[:old_labels] + if old_labels && (issuable.labels != old_labels) + create_labels_note(issuable, issuable.labels - old_labels, old_labels - issuable.labels) + end end end |