Commit 4a1e8188 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-subgroup-autocomplete' into 'master'

Fix users autocomplete in a subgroup

Closes #39452

See merge request gitlab-org/gitlab-ce!15350
parents 148f4079 cf6ff601
...@@ -45,7 +45,7 @@ class AutocompleteUsersFinder ...@@ -45,7 +45,7 @@ class AutocompleteUsersFinder
def find_users def find_users
return users_from_project if project return users_from_project if project
return group.users if group return group.users_with_parents if group
return User.all if current_user return User.all if current_user
User.none User.none
......
---
title: Fix user autocomplete in subgroups
merge_request:
author:
type: fixed
...@@ -42,6 +42,21 @@ describe AutocompleteUsersFinder do ...@@ -42,6 +42,21 @@ describe AutocompleteUsersFinder do
it { is_expected.to match_array([user1]) } it { is_expected.to match_array([user1]) }
end end
context 'when passed a subgroup', :nested_groups do
let(:grandparent) { create(:group, :public) }
let(:parent) { create(:group, :public, parent: grandparent) }
let(:child) { create(:group, :public, parent: parent) }
let(:group) { parent }
let!(:grandparent_user) { create(:group_member, :developer, group: grandparent).user }
let!(:parent_user) { create(:group_member, :developer, group: parent).user }
let!(:child_user) { create(:group_member, :developer, group: child).user }
it 'includes users from parent groups as well' do
expect(subject).to match_array([grandparent_user, parent_user])
end
end
it { is_expected.to match_array([user1, external_user, omniauth_user, current_user]) } it { is_expected.to match_array([user1, external_user, omniauth_user, current_user]) }
context 'when filtered by search' do context 'when filtered by search' do
......
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