Commit 66e83c7d authored by Robert Speicher's avatar Robert Speicher

Merge branch '9083-epics-autocomplete-milestones-in-public-groups' into 'master'

Include public group milestones in epics autocomplete

Closes #9083

See merge request gitlab-org/gitlab-ee!9068
parents dc997fa3 23124367
# frozen_string_literal: true
class ParentGroupsFinder
attr_accessor :user, :group
def initialize(user, group)
@group = group
@user = user
end
# rubocop: disable CodeReuse/ActiveRecord
def execute
group.self_and_ancestors.where(id: user&.authorized_groups)
end
# rubocop: enable CodeReuse/ActiveRecord
end
...@@ -34,12 +34,13 @@ module Groups ...@@ -34,12 +34,13 @@ module Groups
end end
end end
# rubocop: disable CodeReuse/ActiveRecord
def milestones def milestones
group_ids = group_ids = group.self_and_ancestors.public_or_visible_to_user(current_user).pluck(:id)
ParentGroupsFinder.new(current_user, group).execute.map(&:id)
MilestonesFinder.new(group_ids: group_ids).execute.select(:iid, :title) MilestonesFinder.new(group_ids: group_ids).execute.select(:iid, :title)
end end
# rubocop: enable CodeReuse/ActiveRecord
def labels_as_hash(target) def labels_as_hash(target)
super(target, group_id: group.id, only_group_labels: true) super(target, group_id: group.id, only_group_labels: true)
......
---
title: Fix public group milestones not shown in epics autocomplete
merge_request: 9068
author:
type: fixed
...@@ -122,9 +122,6 @@ describe Groups::AutocompleteService do ...@@ -122,9 +122,6 @@ describe Groups::AutocompleteService do
let(:public_subgroup) { create(:group, :public, parent: public_group) } let(:public_subgroup) { create(:group, :public, parent: public_group) }
before do before do
public_subgroup.add_guest(user)
public_group.add_guest(user)
group_milestone.update(group: public_group) group_milestone.update(group: public_group)
subgroup_milestone.update(group: public_subgroup) subgroup_milestone.update(group: public_subgroup)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment