Commit d77843a9 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'fix/group-milestone-autocomplete-members' into 'master'

Group milestone: fix members autocomplete to include users [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!61904
parents dfc52765 382dab46
......@@ -23,9 +23,9 @@ module Groups
end
def group_members
return [] unless noteable
return [] unless group
@group_members ||= sorted(noteable.group.direct_and_indirect_users)
@group_members ||= sorted(group.direct_and_indirect_users)
end
end
end
......@@ -16,6 +16,7 @@ RSpec.describe 'GFM autocomplete', :js do
fill_in 'Description', with: User.reference_prefix
wait_for_requests
expect(find_autocomplete_menu).to be_visible
expect_autocomplete_entry(user.name)
expect_autocomplete_entry(group.name)
fill_in 'Description', with: Label.reference_prefix
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::ParticipantsService do
describe '#group_members' do
let(:user) { create(:user) }
let(:parent_group) { create(:group) }
let(:group) { create(:group, parent: parent_group) }
let(:subgroup) { create(:group, parent: group) }
let(:subproject) { create(:project, group: subgroup) }
it 'returns all members in parent groups, sub-groups, and sub-projects' do
parent_group.add_developer(create(:user))
subgroup.add_developer(create(:user))
subproject.add_developer(create(:user))
result = described_class.new(group, user).execute(nil)
expected_users = (group.self_and_hierarchy.flat_map(&:users) + subproject.users)
.map { |user| user_to_autocompletable(user) }
expect(expected_users.count).to eq(3)
expect(result).to include(*expected_users)
end
end
def user_to_autocompletable(user)
{
type: user.class.name,
username: user.username,
name: user.name,
avatar_url: user.avatar_url,
availability: user&.status&.availability
}
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