project's user search includes group members too

This commit is contained in:
Alexis Reigel 2018-12-11 13:25:52 +01:00
parent d7a3e54be4
commit 241f38b01d
No known key found for this signature in database
GPG key ID: 55ADA7C7B683B329
2 changed files with 20 additions and 4 deletions

View file

@ -30,7 +30,7 @@ module Gitlab
end
def users
super.where(id: @project.users)
super.where(id: @project.team.members) # rubocop:disable CodeReuse/ActiveRecord
end
def blobs_count

View file

@ -414,9 +414,9 @@ describe Gitlab::ProjectSearchResults do
end
describe 'user search' do
let(:project) { create(:project) }
it 'returns the user belonging to the project matching the search query' do
project = create(:project)
it 'returns the users belonging to the project matching the search query' do
user1 = create(:user, username: 'gob_bluth')
create(:project_member, :developer, user: user1, project: project)
@ -425,7 +425,23 @@ describe Gitlab::ProjectSearchResults do
create(:user, username: 'gob_2018')
expect(described_class.new(user, project, 'gob').objects('users')).to eq [user1]
result = described_class.new(user, project, 'gob').objects('users')
expect(result).to eq [user1]
end
it 'returns the user belonging to the group matching the search query' do
group = create(:group)
project = create(:project, namespace: group)
user1 = create(:user, username: 'gob_bluth')
create(:group_member, :developer, user: user1, group: group)
create(:user, username: 'gob_2018')
result = described_class.new(user, project, 'gob').objects('users')
expect(result).to eq [user1]
end
end
end