Commit 9d8aaa13 authored by David Fernandez's avatar David Fernandez

Merge branch 'vij-sm-pending-user-count' into 'master'

Support the display of pending user count when modifying user cap

See merge request gitlab-org/gitlab!66619
parents d11bc7e5 71d90864
...@@ -447,6 +447,12 @@ module ApplicationSettingsHelper ...@@ -447,6 +447,12 @@ module ApplicationSettingsHelper
def signup_enabled? def signup_enabled?
!!Gitlab::CurrentSettings.signup_enabled !!Gitlab::CurrentSettings.signup_enabled
end end
def pending_user_count
return 0 if Gitlab::CurrentSettings.new_user_signups_cap.blank?
User.blocked_pending_approval.count
end
end end
ApplicationSettingsHelper.prepend_mod_with('ApplicationSettingsHelper') ApplicationSettingsHelper.prepend_mod_with('ApplicationSettingsHelper')
......
...@@ -17,4 +17,5 @@ ...@@ -17,4 +17,5 @@
email_restrictions_enabled: @application_setting[:email_restrictions_enabled].to_s, email_restrictions_enabled: @application_setting[:email_restrictions_enabled].to_s,
supported_syntax_link_url: 'https://github.com/google/re2/wiki/Syntax', supported_syntax_link_url: 'https://github.com/google/re2/wiki/Syntax',
email_restrictions: @application_setting.email_restrictions, email_restrictions: @application_setting.email_restrictions,
after_sign_up_text: @application_setting[:after_sign_up_text] } } after_sign_up_text: @application_setting[:after_sign_up_text],
pending_user_count: pending_user_count } }
...@@ -254,4 +254,34 @@ RSpec.describe ApplicationSettingsHelper do ...@@ -254,4 +254,34 @@ RSpec.describe ApplicationSettingsHelper do
]) ])
end end
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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment