diff options
author | Mark Chao <mchao@gitlab.com> | 2018-07-04 12:52:58 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-07-04 15:48:50 +0300 |
commit | 4f795ed823776912e8e9d6d4eb33c345ad2b56b9 (patch) | |
tree | c4886e114c6de12600c5ad25e5ab9a6cb9257342 /app/services/labels | |
parent | ecf9c145f6e4d170cd059df88743393d9e63c489 (diff) |
Backport from EE !5954
Allow Labels::FindOrCreateService to find ancestor group labels
Add authentication check on API endpoint
Update flayignore
Diffstat (limited to 'app/services/labels')
-rw-r--r-- | app/services/labels/find_or_create_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/labels/find_or_create_service.rb b/app/services/labels/find_or_create_service.rb index 079f611b3f3..a72da3c637f 100644 --- a/app/services/labels/find_or_create_service.rb +++ b/app/services/labels/find_or_create_service.rb @@ -20,6 +20,7 @@ module Labels @available_labels ||= LabelsFinder.new( current_user, "#{parent_type}_id".to_sym => parent.id, + include_ancestor_groups: include_ancestor_groups?, only_group_labels: parent_is_group? ).execute(skip_authorization: skip_authorization) end @@ -30,7 +31,8 @@ module Labels new_label = available_labels.find_by(title: title) if new_label.nil? && (skip_authorization || Ability.allowed?(current_user, :admin_label, parent)) - new_label = Labels::CreateService.new(params).execute(parent_type.to_sym => parent) + create_params = params.except(:include_ancestor_groups) + new_label = Labels::CreateService.new(create_params).execute(parent_type.to_sym => parent) end new_label @@ -47,5 +49,9 @@ module Labels def parent_is_group? parent_type == "group" end + + def include_ancestor_groups? + params[:include_ancestor_groups] == true + end end end |