diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2018-09-20 10:13:39 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2019-01-31 13:49:50 +0100 |
commit | ee826ad4a11560e669833cd9df707750a1e86b93 (patch) | |
tree | 901e666ac9b5e1c336d168d23d6fdeef8a6c5c1d | |
parent | 82f09a91dd3abae48b74010f541ea50e0190276a (diff) | |
download | gitlab-ce-ee826ad4a11560e669833cd9df707750a1e86b93.tar.gz |
Replace finders
-rw-r--r-- | lib/api/group_labels.rb | 6 | ||||
-rw-r--r-- | lib/api/helpers.rb | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/api/group_labels.rb b/lib/api/group_labels.rb index fb2d7fedb90..d8be226f045 100644 --- a/lib/api/group_labels.rb +++ b/lib/api/group_labels.rb @@ -35,7 +35,7 @@ module API post ':id/labels' do authorize! :admin_label, user_group - label = available_labels_for(user_group).find_by(title: params[:name]) + label = available_labels_for(user_group, { title: params[:name] }) conflict!('Label already exists') if label label = ::Labels::CreateService.new(declared_params(include_missing: false)).execute(group: user_group) @@ -57,7 +57,7 @@ module API delete ':id/labels' do authorize! :admin_label, user_group - label = user_group.labels.find_by(title: params[:name]) + label = available_labels_for(user_group, { title: params[:name] }) not_found!('Label') unless label destroy_conditionally!(label) @@ -77,7 +77,7 @@ module API put ':id/labels' do authorize! :admin_label, user_group - label = user_group.labels.find_by(title: params[:name]) + label = available_labels_for(user_group, { title: params[:name] }) not_found!('Label not found') unless label label = ::Labels::UpdateService.new(declared_params(include_missing: false)).execute(label) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 544736c42f4..ccfadef2736 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -84,8 +84,8 @@ module API page || not_found!('Wiki Page') end - def available_labels_for(label_parent) - search_params = { include_ancestor_groups: true } + def available_labels_for(label_parent, search_params = {}) + search_params.merge(include_ancestor_groups: true) if label_parent.is_a?(Project) search_params[:project_id] = label_parent.id |