diff options
author | Sean McGivern <sean@gitlab.com> | 2016-05-31 14:45:55 +0300 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-06-04 01:14:23 +0300 |
commit | 071ad63630c2f8f9666c0c1fae6b6b3491e3cf9f (patch) | |
tree | 01a24b7d918d21ef4ad2716af23344ab5c898571 /app | |
parent | 165d799fb3ca36768497d964619ceeacf2deeae3 (diff) |
Spec label add / delete in UpdateService
Diffstat (limited to 'app')
-rw-r--r-- | app/services/issuable_base_service.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index fbe9b7d7f16..e3dc569152c 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -72,18 +72,17 @@ class IssuableBaseService < BaseService if params[:add_label_ids].present? || params[:remove_label_ids].present? params.delete(:label_ids) - filter_labels_by_name([:add_label_ids, :remove_label_ids]) + filter_labels_in_param(:add_label_ids) + filter_labels_in_param(:remove_label_ids) else - filter_labels_by_name([:label_ids]) + filter_labels_in_param(:label_ids) end end - def filter_labels_by_name(keys) - keys.each do |key| - next if params[key].to_a.empty? + def filter_labels_in_param(key) + return if params[key].to_a.empty? - params[key] = project.labels.where(id: params[key]).pluck(:id) - end + params[key] = project.labels.where(id: params[key]).pluck(:id) end def update_issuable(issuable, attributes) @@ -94,7 +93,7 @@ class IssuableBaseService < BaseService issuable.label_ids |= add_label_ids if add_label_ids issuable.label_ids -= remove_label_ids if remove_label_ids - issuable.assign_attributes(attributes) + issuable.assign_attributes(attributes.merge(updated_by: current_user)) issuable.save end @@ -105,7 +104,7 @@ class IssuableBaseService < BaseService filter_params old_labels = issuable.labels.to_a - if params.present? && update_issuable(issuable, params.merge(updated_by: current_user)) + if params.present? && update_issuable(issuable, params) issuable.reset_events_cache handle_common_system_notes(issuable, old_labels: old_labels) handle_changes(issuable, old_labels: old_labels) |