summaryrefslogtreecommitdiff
path: root/spec/helpers/application_settings_helper_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/helpers/application_settings_helper_spec.rb
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
downloadgitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/helpers/application_settings_helper_spec.rb')
-rw-r--r--spec/helpers/application_settings_helper_spec.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index 90bfb2e72e6..6d51d85fd64 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -238,7 +238,7 @@ RSpec.describe ApplicationSettingsHelper do
expect(helper.kroki_available_formats).to eq([
{
name: 'kroki_formats_blockdiag',
- label: 'BlockDiag (includes BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag and RackDiag)',
+ label: 'BlockDiag (includes BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, and RackDiag)',
value: true
},
{
@@ -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