diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/lib/gitlab/project_search_results_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/lib/gitlab/project_search_results_spec.rb')
-rw-r--r-- | spec/lib/gitlab/project_search_results_spec.rb | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index a76ad1f6f4c..2f28b8dfce0 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -549,30 +549,39 @@ RSpec.describe Gitlab::ProjectSearchResults do describe 'user search' do let(:query) { 'gob' } - let(:group) { create(:group) } - let(:project) { create(:project, namespace: group) } + + let_it_be(:user_1) { create(:user, username: 'gob_bluth') } + let_it_be(:user_2) { create(:user, username: 'michael_bluth') } + let_it_be(:user_3) { create(:user, username: 'gob_2018') } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, namespace: group) } subject(:objects) { results.objects('users') } it 'returns the user belonging to the project matching the search query' do - user1 = create(:user, username: 'gob_bluth') - create(:project_member, :developer, user: user1, project: project) + create(:project_member, :developer, user: user_1, project: project) + create(:project_member, :developer, user: user_2, project: project) - user2 = create(:user, username: 'michael_bluth') - create(:project_member, :developer, user: user2, project: project) + expect(objects).to contain_exactly(user_1) + end - create(:user, username: 'gob_2018') + it 'returns the user belonging to the group matching the search query' do + create(:group_member, :developer, user: user_1, group: group) - expect(objects).to contain_exactly(user1) + expect(objects).to contain_exactly(user_1) end - it 'returns the user belonging to the group matching the search query' do - user1 = create(:user, username: 'gob_bluth') - create(:group_member, :developer, user: user1, group: group) + context 'when multiple projects provided' do + let_it_be(:project_2) { create(:project, namespace: group) } + + subject(:results) { described_class.new(user, query, project: [project, project_2], repository_ref: repository_ref, filters: filters) } - create(:user, username: 'gob_2018') + it 'returns users belonging to projects matching the search query' do + create(:project_member, :developer, user: user_1, project: project) + create(:project_member, :developer, user: user_3, project: project_2) - expect(objects).to contain_exactly(user1) + expect(objects).to contain_exactly(user_1, user_3) + end end end end |