diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/finders/autocomplete/users_finder_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/finders/autocomplete/users_finder_spec.rb')
-rw-r--r-- | spec/finders/autocomplete/users_finder_spec.rb | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/spec/finders/autocomplete/users_finder_spec.rb b/spec/finders/autocomplete/users_finder_spec.rb index de031041e18..57f804e471f 100644 --- a/spec/finders/autocomplete/users_finder_spec.rb +++ b/spec/finders/autocomplete/users_finder_spec.rb @@ -8,7 +8,8 @@ RSpec.describe Autocomplete::UsersFinder do describe '#execute' do let_it_be(:user1) { create(:user, name: 'zzzzzname', username: 'johndoe') } - let_it_be(:user2) { create(:user, :blocked, username: 'notsorandom') } + let_it_be(:blocked_user) { create(:user, :blocked, username: 'blocked_user') } + let_it_be(:banned_user) { create(:user, :banned, username: 'banned_user') } let_it_be(:external_user) { create(:user, :external) } let_it_be(:omniauth_user) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') } @@ -39,7 +40,13 @@ RSpec.describe Autocomplete::UsersFinder do end context 'and author is blocked' do - let(:params) { { author_id: user2.id } } + let(:params) { { author_id: blocked_user.id } } + + it { is_expected.to match_array([project.first_owner]) } + end + + context 'and author is banned' do + let(:params) { { author_id: banned_user.id } } it { is_expected.to match_array([project.first_owner]) } end @@ -108,7 +115,7 @@ RSpec.describe Autocomplete::UsersFinder do end context 'when filtered by skip_users' do - let(:params) { { skip_users: [omniauth_user.id, current_user.id] } } + let(:params) { { skip_users: [omniauth_user.id, current_user.id, blocked_user] } } it { is_expected.to match_array([user1, external_user]) } end @@ -139,10 +146,10 @@ RSpec.describe Autocomplete::UsersFinder do end context 'when filtered by current_user' do - let(:current_user) { user2 } + let(:current_user) { blocked_user } let(:params) { { current_user: true } } - it { is_expected.to match_array([user2, user1, external_user, omniauth_user]) } + it { is_expected.to match_array([blocked_user, user1, external_user, omniauth_user]) } end context 'when filtered by author_id' do @@ -155,5 +162,37 @@ RSpec.describe Autocomplete::UsersFinder do associations = subject.map { |user| user.association(:status) } expect(associations).to all(be_loaded) end + + context 'when filtered by state' do + context "searching without states" do + let(:params) { { states: nil } } + + it { is_expected.to match_array([user1, external_user, omniauth_user, current_user]) } + end + + context "searching with states=active" do + let(:params) { { states: %w[active] } } + + it { is_expected.to match_array([user1, external_user, omniauth_user, current_user]) } + end + + context "searching with states=blocked" do + let(:params) { { states: %w[blocked] } } + + it { is_expected.to match_array([blocked_user]) } + end + + context "searching with states=banned" do + let(:params) { { states: %w[banned] } } + + it { is_expected.to match_array([banned_user]) } + end + + context "searching with states=blocked,banned" do + let(:params) { { states: %w[blocked banned] } } + + it { is_expected.to match_array([blocked_user, banned_user]) } + end + end end end |