Merge branch 'rails5-fix-47836' into 'master'

Rails5 fix passing Group objects array into for_projects_and_groups milestone scope

Closes #47836

See merge request gitlab-org/gitlab-ce!19863
This commit is contained in:
Yorick Peterse 2018-06-15 13:22:24 +00:00
commit 1ed954e8a7
3 changed files with 9 additions and 3 deletions

View file

@ -123,9 +123,9 @@ class Projects::MilestonesController < Projects::ApplicationController
def search_params def search_params
if request.format.json? && @project.group && can?(current_user, :read_group, @project.group) if request.format.json? && @project.group && can?(current_user, :read_group, @project.group)
groups = @project.group.self_and_ancestors groups = @project.group.self_and_ancestors_ids
end end
params.permit(:state).merge(project_ids: @project.id, group_ids: groups&.select(:id)) params.permit(:state).merge(project_ids: @project.id, group_ids: groups)
end end
end end

View file

@ -0,0 +1,6 @@
---
title: Rails5 fix passing Group objects array into for_projects_and_groups milestone
scope
merge_request: 19863
author: Jasper Maes
type: fixed

View file

@ -65,7 +65,7 @@ module Banzai
# We don't support IID lookups for group milestones, because IIDs can # We don't support IID lookups for group milestones, because IIDs can
# clash between group and project milestones. # clash between group and project milestones.
if project.group && !params[:iid] if project.group && !params[:iid]
finder_params[:group_ids] = project.group.self_and_ancestors.select(:id) finder_params[:group_ids] = project.group.self_and_ancestors_ids
end end
MilestonesFinder.new(finder_params).find_by(params) MilestonesFinder.new(finder_params).find_by(params)