summaryrefslogtreecommitdiff
path: root/spec/helpers/application_settings_helper_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-27 12:10:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-27 12:10:54 +0000
commit7a20b3758e651fe79032a5165db2208183877317 (patch)
treeca4964f3e851cd4b77879652aec225ea5daa1ca4 /spec/helpers/application_settings_helper_spec.rb
parent2458ea514066142e3ca8e5131e44925398902a77 (diff)
downloadgitlab-ce-7a20b3758e651fe79032a5165db2208183877317.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers/application_settings_helper_spec.rb')
-rw-r--r--spec/helpers/application_settings_helper_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index 654d4116519..6d51d85fd64 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -254,4 +254,34 @@ RSpec.describe ApplicationSettingsHelper do
])
end
end
+
+ describe '.pending_user_count' do
+ let(:user_cap) { 200 }
+
+ before do
+ stub_application_setting(new_user_signups_cap: user_cap)
+ end
+
+ subject(:pending_user_count) { helper.pending_user_count }
+
+ context 'when new_user_signups_cap is present' do
+ it 'returns the number of blocked pending users' do
+ create(:user, state: :blocked_pending_approval)
+
+ expect(pending_user_count).to eq 1
+ end
+ end
+
+ context 'when the new_user_signups_cap is not present' do
+ let(:user_cap) { nil }
+
+ it { is_expected.to eq 0 }
+
+ it 'does not query users unnecessarily' do
+ expect(User).not_to receive(:blocked_pending_approval)
+
+ pending_user_count
+ end
+ end
+ end
end