Commit 71d90864 authored by Vijay Hawoldar's avatar Vijay Hawoldar

Support pending user count display

Backend support for showing an instance admin pending
users when they remove or increase a user cap on their
instance
parent fcc19300
......@@ -447,6 +447,12 @@ module ApplicationSettingsHelper
def signup_enabled?
!!Gitlab::CurrentSettings.signup_enabled
end
def pending_user_count
return 0 if Gitlab::CurrentSettings.new_user_signups_cap.blank?
User.blocked_pending_approval.count
end
end
ApplicationSettingsHelper.prepend_mod_with('ApplicationSettingsHelper')
......
......@@ -17,4 +17,5 @@
email_restrictions_enabled: @application_setting[:email_restrictions_enabled].to_s,
supported_syntax_link_url: 'https://github.com/google/re2/wiki/Syntax',
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
])
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
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