diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-18 22:19:13 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-18 22:29:49 +0300 |
commit | 6f2f2a6baae128cd4f8111d91bdcfb7b76e39b97 (patch) | |
tree | c3400a922365756dc86560c784189805f306a05c | |
parent | 9aa3edc61586fd79ce0760b7af0946ddfadaa65a (diff) |
Fix behavior of label_ids and add/remove_label_ids
-rw-r--r-- | app/services/issuable_base_service.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb index 57286f255f4..3100bd58818 100644 --- a/app/services/issuable_base_service.rb +++ b/app/services/issuable_base_service.rb @@ -80,18 +80,19 @@ class IssuableBaseService < BaseService params[key] = project.labels.where(id: params[key]).pluck(:id) end - def process_label_ids(attributes, existing_label_ids: []) + def process_label_ids(attributes, existing_label_ids: nil) label_ids = attributes.delete(:label_ids) add_label_ids = attributes.delete(:add_label_ids) remove_label_ids = attributes.delete(:remove_label_ids) - new_label_ids = existing_label_ids + new_label_ids = existing_label_ids || label_ids || [] - override_existing = new_label_ids.empty? || (add_label_ids.blank? && remove_label_ids.blank?) - new_label_ids = label_ids if label_ids && override_existing - - new_label_ids |= add_label_ids if add_label_ids - new_label_ids -= remove_label_ids if remove_label_ids + if add_label_ids.blank? && remove_label_ids.blank? + new_label_ids = label_ids if label_ids + else + new_label_ids |= add_label_ids if add_label_ids + new_label_ids -= remove_label_ids if remove_label_ids + end new_label_ids end |