From 3778a136e1c573443be3aabae30397262ec74460 Mon Sep 17 00:00:00 2001 From: Jasper Maes Date: Thu, 14 Jun 2018 18:39:21 +0200 Subject: [PATCH] Rails5 fix passing Group objects array into for_projects_and_groups milestone scope --- app/controllers/projects/milestones_controller.rb | 4 ++-- changelogs/unreleased/rails5-fix-47836.yml | 6 ++++++ lib/banzai/filter/milestone_reference_filter.rb | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/rails5-fix-47836.yml diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 2494b56981d..f85dcfe6bfc 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -123,9 +123,9 @@ class Projects::MilestonesController < Projects::ApplicationController def search_params 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 - 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 diff --git a/changelogs/unreleased/rails5-fix-47836.yml b/changelogs/unreleased/rails5-fix-47836.yml new file mode 100644 index 00000000000..2aef2db607a --- /dev/null +++ b/changelogs/unreleased/rails5-fix-47836.yml @@ -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 diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb index 858e790005c..af8448937b3 100644 --- a/lib/banzai/filter/milestone_reference_filter.rb +++ b/lib/banzai/filter/milestone_reference_filter.rb @@ -65,7 +65,7 @@ module Banzai # We don't support IID lookups for group milestones, because IIDs can # clash between group and project milestones. 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 MilestonesFinder.new(finder_params).find_by(params)