Skip to content
Snippets Groups Projects
Commit ee826ad4 authored by Robert Schilling's avatar Robert Schilling
Browse files

Replace finders

parent 82f09a91
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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)
Loading
Loading
@@ -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)
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment