diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/finders/users_finder_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/finders/users_finder_spec.rb')
-rw-r--r-- | spec/finders/users_finder_spec.rb | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/spec/finders/users_finder_spec.rb b/spec/finders/users_finder_spec.rb index fab48cf3178..271dce44db7 100644 --- a/spec/finders/users_finder_spec.rb +++ b/spec/finders/users_finder_spec.rb @@ -6,13 +6,15 @@ RSpec.describe UsersFinder do describe '#execute' do include_context 'UsersFinder#execute filter by project context' + let_it_be(:project_bot) { create(:user, :project_bot) } + context 'with a normal user' do - let(:user) { create(:user) } + let_it_be(:user) { create(:user) } - it 'returns all users' do + it 'returns searchable users' do users = described_class.new(user).execute - expect(users).to contain_exactly(user, normal_user, blocked_user, external_user, omniauth_user, internal_user, admin_user) + expect(users).to contain_exactly(user, normal_user, external_user, unconfirmed_user, omniauth_user, internal_user, admin_user, project_bot) end it 'filters by username' do @@ -34,9 +36,9 @@ RSpec.describe UsersFinder do end it 'filters by search' do - users = described_class.new(user, search: 'orando').execute + users = described_class.new(user, search: 'ohndo').execute - expect(users).to contain_exactly(blocked_user) + expect(users).to contain_exactly(normal_user) end it 'does not filter by private emails search' do @@ -45,18 +47,6 @@ RSpec.describe UsersFinder do expect(users).to be_empty end - it 'filters by blocked users' do - users = described_class.new(user, blocked: true).execute - - expect(users).to contain_exactly(blocked_user) - end - - it 'filters by active users' do - users = described_class.new(user, active: true).execute - - expect(users).to contain_exactly(user, normal_user, external_user, omniauth_user, admin_user) - end - it 'filters by external users' do users = described_class.new(user, external: true).execute @@ -66,7 +56,7 @@ RSpec.describe UsersFinder do it 'filters by non external users' do users = described_class.new(user, non_external: true).execute - expect(users).to contain_exactly(user, normal_user, blocked_user, omniauth_user, internal_user, admin_user) + expect(users).to contain_exactly(user, normal_user, unconfirmed_user, omniauth_user, internal_user, admin_user, project_bot) end it 'filters by created_at' do @@ -83,7 +73,7 @@ RSpec.describe UsersFinder do it 'filters by non internal users' do users = described_class.new(user, non_internal: true).execute - expect(users).to contain_exactly(user, normal_user, external_user, blocked_user, omniauth_user, admin_user) + expect(users).to contain_exactly(user, normal_user, unconfirmed_user, external_user, omniauth_user, admin_user, project_bot) end it 'does not filter by custom attributes' do @@ -92,23 +82,23 @@ RSpec.describe UsersFinder do custom_attributes: { foo: 'bar' } ).execute - expect(users).to contain_exactly(user, normal_user, blocked_user, external_user, omniauth_user, internal_user, admin_user) + expect(users).to contain_exactly(user, normal_user, external_user, unconfirmed_user, omniauth_user, internal_user, admin_user, project_bot) end it 'orders returned results' do users = described_class.new(user, sort: 'id_asc').execute - expect(users).to eq([normal_user, admin_user, blocked_user, external_user, omniauth_user, internal_user, user]) + expect(users).to eq([normal_user, admin_user, external_user, unconfirmed_user, omniauth_user, internal_user, project_bot, user]) end it 'does not filter by admins' do users = described_class.new(user, admins: true).execute - expect(users).to contain_exactly(user, normal_user, external_user, admin_user, blocked_user, omniauth_user, internal_user) + expect(users).to contain_exactly(user, normal_user, external_user, admin_user, unconfirmed_user, omniauth_user, internal_user, project_bot) end end context 'with an admin user', :enable_admin_mode do - let(:admin) { create(:admin) } + let_it_be(:admin) { create(:admin) } it 'filters by external users' do users = described_class.new(admin, external: true).execute @@ -119,7 +109,19 @@ RSpec.describe UsersFinder do it 'returns all users' do users = described_class.new(admin).execute - expect(users).to contain_exactly(admin, normal_user, blocked_user, external_user, omniauth_user, internal_user, admin_user) + expect(users).to contain_exactly(admin, normal_user, blocked_user, unconfirmed_user, banned_user, external_user, omniauth_user, internal_user, admin_user, project_bot) + end + + it 'filters by blocked users' do + users = described_class.new(admin, blocked: true).execute + + expect(users).to contain_exactly(blocked_user) + end + + it 'filters by active users' do + users = described_class.new(admin, active: true).execute + + expect(users).to contain_exactly(admin, normal_user, unconfirmed_user, external_user, omniauth_user, admin_user, project_bot) end it 'returns only admins' do |