Correctly search for labels in parent groups

This commit is contained in:
Robert Schilling 2019-01-03 15:07:13 +01:00
parent 22d2a48006
commit 4e9aa7e2c0
2 changed files with 6 additions and 6 deletions

View file

@ -57,7 +57,7 @@ module API
delete ':id/labels' do
authorize! :admin_label, user_group
label = find_label(user_group, params[:name])
label = find_label(user_group, params[:name], false)
destroy_conditionally!(label)
end
@ -76,7 +76,7 @@ module API
put ':id/labels' do
authorize! :admin_label, user_group
label = find_label(user_group, params[:name])
label = find_label(user_group, params[:name], false)
label = ::Labels::UpdateService.new(declared_params(include_missing: false)).execute(label)
render_validation_error!(label) unless label.valid?

View file

@ -84,8 +84,8 @@ module API
page || not_found!('Wiki Page')
end
def available_labels_for(label_parent, search_params = {})
search_params.merge(include_ancestor_groups: true)
def available_labels_for(label_parent, include_ancestor_groups = true)
search_params = { include_ancestor_groups: include_ancestor_groups }
if label_parent.is_a?(Project)
search_params[:project_id] = label_parent.id
@ -170,8 +170,8 @@ module API
end
end
def find_label(parent, id)
labels = available_labels_for(parent)
def find_label(parent, id, include_ancestor_groups = true)
labels = available_labels_for(parent, include_ancestor_groups)
label = labels.find_by_id(id) || labels.find_by_title(id)
label || not_found!('Label')