Commit d908fcb2 authored by Amparo Luna's avatar Amparo Luna Committed by Andrew Fontaine

Remove feature flag usages

The :admin_new_user_signups_cap feature is no longer needed.
parent bd3a20b8
...@@ -62,7 +62,7 @@ module EE ...@@ -62,7 +62,7 @@ module EE
attrs << :maintenance_mode_message attrs << :maintenance_mode_message
end end
attrs << :new_user_signups_cap if ::Feature.enabled?(:admin_new_user_signups_cap, default_enabled: true ) attrs << :new_user_signups_cap
attrs attrs
end end
......
...@@ -84,7 +84,6 @@ module EE ...@@ -84,7 +84,6 @@ module EE
end end
def show_new_user_signups_cap_reached? def show_new_user_signups_cap_reached?
return false unless ::Feature.enabled?(:admin_new_user_signups_cap, default_enabled: true )
return false unless current_user&.admin? return false unless current_user&.admin?
return false if user_dismissed?(NEW_USER_SIGNUPS_CAP_REACHED) return false if user_dismissed?(NEW_USER_SIGNUPS_CAP_REACHED)
......
...@@ -358,8 +358,7 @@ module EE ...@@ -358,8 +358,7 @@ module EE
end end
def should_apply_user_signup_cap? def should_apply_user_signup_cap?
::Feature.enabled?(:admin_new_user_signups_cap, default_enabled: true ) && ::Gitlab::CurrentSettings.new_user_signups_cap.present?
::Gitlab::CurrentSettings.new_user_signups_cap.present?
end end
private private
......
...@@ -52,7 +52,6 @@ module EE ...@@ -52,7 +52,6 @@ module EE
def user_cap_increased? def user_cap_increased?
return false unless application_setting.previous_changes.key?(:new_user_signups_cap) return false unless application_setting.previous_changes.key?(:new_user_signups_cap)
return false unless ::Feature.enabled?(:admin_new_user_signups_cap, default_enabled: true )
previous_user_cap, current_user_cap = application_setting.previous_changes[:new_user_signups_cap] previous_user_cap, current_user_cap = application_setting.previous_changes[:new_user_signups_cap]
......
- return unless ::Feature.enabled?(:admin_new_user_signups_cap, default_enabled: true )
.form-group .form-group
= form.label :new_user_signups_cap, s_('AdminArea|User cap'), class: 'label-bold' = form.label :new_user_signups_cap, s_('AdminArea|User cap'), class: 'label-bold'
= form.number_field :new_user_signups_cap, class: 'form-control gl-form-input', max: License.current&.restricted_user_count = form.number_field :new_user_signups_cap, class: 'form-control gl-form-input', max: License.current&.restricted_user_count
......
---
name: admin_new_user_signups_cap
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45643
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/292600
milestone: '13.6'
type: development
group: group::purchase
default_enabled: true
...@@ -74,39 +74,17 @@ RSpec.describe RegistrationsController do ...@@ -74,39 +74,17 @@ RSpec.describe RegistrationsController do
end end
end end
context 'when user signup cap setting is enabled' do context 'when user signup cap is set' do
before do before do
stub_application_setting(new_user_signups_cap: true) stub_application_setting(new_user_signups_cap: 1)
end end
it_behaves_like 'blocked user by default' it_behaves_like 'blocked user by default'
context 'when feature flag is disabled' do
before do
stub_feature_flags(admin_new_user_signups_cap: false)
end
context 'when require admin approval setting is disabled' do
before do
stub_application_setting(require_admin_approval_after_user_signup: false)
end
it_behaves_like 'active user by default'
end
context 'when require admin approval setting is enabled' do
before do
stub_application_setting(require_admin_approval_after_user_signup: true)
end
it_behaves_like 'blocked user by default'
end
end
end end
context 'when user signup cap setting is disabled' do context 'when user signup cap is not set' do
before do before do
stub_application_setting(admin_new_user_signups_cap: false) stub_application_setting(new_user_signups_cap: nil)
end end
context 'when require admin approval setting is disabled' do context 'when require admin approval setting is disabled' do
......
...@@ -281,70 +281,52 @@ RSpec.describe 'Admin updates EE-only settings' do ...@@ -281,70 +281,52 @@ RSpec.describe 'Admin updates EE-only settings' do
end end
context 'sign up settings' do context 'sign up settings' do
context 'when feature flag is disabled' do context 'when license has active user count' do
before do let(:license) { create(:license, restrictions: { active_user_count: 1 }) }
stub_feature_flags(admin_new_user_signups_cap: false)
end
it 'does not render user cap form group' do
visit general_admin_application_settings_path
expect(page).not_to have_field('User cap')
end
end
context 'when feature flag is enabled' do
before do before do
stub_feature_flags(admin_new_user_signups_cap: true) allow(License).to receive(:current).and_return(license)
end end
context 'when license has active user count' do it 'disallows entering user cap greater then license allows', :js do
let(:license) { create(:license, restrictions: { active_user_count: 1 }) } visit general_admin_application_settings_path
before do
allow(License).to receive(:current).and_return(license)
end
it 'disallows entering user cap greater then license allows', :js do
visit general_admin_application_settings_path
page.within('#js-signup-settings') do page.within('#js-signup-settings') do
fill_in 'User cap', with: 5 fill_in 'User cap', with: 5
click_button 'Save changes' click_button 'Save changes'
message = message =
page.find('#application_setting_new_user_signups_cap').native.attribute('validationMessage') page.find('#application_setting_new_user_signups_cap').native.attribute('validationMessage')
expect(message).to eq('Value must be less than or equal to 1.') expect(message).to eq('Value must be less than or equal to 1.')
end
end end
end end
end
it 'changes the user cap from unlimited to 5' do it 'changes the user cap from unlimited to 5' do
visit general_admin_application_settings_path visit general_admin_application_settings_path
expect(current_settings.new_user_signups_cap).to be_nil expect(current_settings.new_user_signups_cap).to be_nil
page.within('#js-signup-settings') do page.within('#js-signup-settings') do
fill_in 'User cap', with: 5 fill_in 'User cap', with: 5
click_button 'Save changes' click_button 'Save changes'
expect(current_settings.new_user_signups_cap).to eq(5) expect(current_settings.new_user_signups_cap).to eq(5)
end
end end
end
it 'changes the user cap to unlimited' do it 'changes the user cap to unlimited' do
visit general_admin_application_settings_path visit general_admin_application_settings_path
page.within('#js-signup-settings') do page.within('#js-signup-settings') do
fill_in 'User cap', with: nil fill_in 'User cap', with: nil
click_button 'Save changes' click_button 'Save changes'
expect(current_settings.new_user_signups_cap).to be_nil expect(current_settings.new_user_signups_cap).to be_nil
end
end end
end end
end end
......
...@@ -351,15 +351,6 @@ RSpec.describe EE::UserCalloutsHelper do ...@@ -351,15 +351,6 @@ RSpec.describe EE::UserCalloutsHelper do
it { is_expected.to eq(false) } it { is_expected.to eq(false) }
end end
context 'when feature flag is disabled' do
before do
allow(helper).to receive(:current_user).and_return(admin)
stub_feature_flags(admin_new_user_signups_cap: false)
end
it { is_expected.to eq(false) }
end
context 'when feature flag is enabled' do context 'when feature flag is enabled' do
where(:new_user_signups_cap, :active_user_count, :result) do where(:new_user_signups_cap, :active_user_count, :result) do
nil | 10 | false nil | 10 | false
......
...@@ -766,30 +766,20 @@ RSpec.describe ApplicationSetting do ...@@ -766,30 +766,20 @@ RSpec.describe ApplicationSetting do
describe '#should_apply_user_signup_cap?' do describe '#should_apply_user_signup_cap?' do
subject { setting.should_apply_user_signup_cap? } subject { setting.should_apply_user_signup_cap? }
context 'when feature admin_new_user_signups_cap is disabled' do before do
before do allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(new_user_signups_cap)
stub_feature_flags(admin_new_user_signups_cap: false)
end
it { is_expected.to be false }
end end
context 'when feature admin_new_user_signups_cap is enabled' do context 'when new_user_signups_cap setting is nil' do
before do let(:new_user_signups_cap) { nil }
allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(new_user_signups_cap)
end
context 'when new_user_signups_cap setting is nil' do
let(:new_user_signups_cap) { nil }
it { is_expected.to be false } it { is_expected.to be false }
end end
context 'when new_user_signups_cap setting is set to any number' do context 'when new_user_signups_cap setting is set to any number' do
let(:new_user_signups_cap) { 10 } let(:new_user_signups_cap) { 10 }
it { is_expected.to be true } it { is_expected.to be true }
end
end end
end end
end end
...@@ -107,18 +107,6 @@ RSpec.describe User do ...@@ -107,18 +107,6 @@ RSpec.describe User do
allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(new_user_signups_cap) allow(Gitlab::CurrentSettings).to receive(:new_user_signups_cap).and_return(new_user_signups_cap)
end end
context 'when feature is disabled' do
before do
stub_feature_flags(admin_new_user_signups_cap: false)
end
it 'does not call SetUserStatusBasedOnUserCapSettingWorker' do
expect(SetUserStatusBasedOnUserCapSettingWorker).not_to receive(:perform_async)
create(:user, state: 'blocked_pending_approval')
end
end
context 'when user cap is not set' do context 'when user cap is not set' do
it 'does not call SetUserStatusBasedOnUserCapSettingWorker' do it 'does not call SetUserStatusBasedOnUserCapSettingWorker' do
expect(SetUserStatusBasedOnUserCapSettingWorker).not_to receive(:perform_async) expect(SetUserStatusBasedOnUserCapSettingWorker).not_to receive(:perform_async)
......
...@@ -7,7 +7,6 @@ RSpec.describe 'callout alerts' do ...@@ -7,7 +7,6 @@ RSpec.describe 'callout alerts' do
describe 'new_user_signups_cap_reached' do describe 'new_user_signups_cap_reached' do
let_it_be(:user) { create(:admin) } let_it_be(:user) { create(:admin) }
let(:enabled) { true }
let(:billable_users) { [double(:billable_user)] } let(:billable_users) { [double(:billable_user)] }
let(:help_page_href) { help_page_path('user/admin_area/settings/sign_up_restrictions.md') } let(:help_page_href) { help_page_path('user/admin_area/settings/sign_up_restrictions.md') }
let(:expected_content) { 'Your instance has reached its user cap' } let(:expected_content) { 'Your instance has reached its user cap' }
...@@ -30,7 +29,6 @@ RSpec.describe 'callout alerts' do ...@@ -30,7 +29,6 @@ RSpec.describe 'callout alerts' do
end end
before do before do
stub_feature_flags(admin_new_user_signups_cap: enabled)
stub_application_setting(new_user_signups_cap: 1) stub_application_setting(new_user_signups_cap: 1)
allow(User).to receive(:billable).and_return(billable_users) allow(User).to receive(:billable).and_return(billable_users)
...@@ -47,12 +45,6 @@ RSpec.describe 'callout alerts' do ...@@ -47,12 +45,6 @@ RSpec.describe 'callout alerts' do
it_behaves_like 'a hidden alert' it_behaves_like 'a hidden alert'
end end
context 'when feature disabled' do
let(:enabled) { false }
it_behaves_like 'a hidden alert'
end
context 'when user is not admin' do context 'when user is not admin' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
......
...@@ -234,16 +234,6 @@ RSpec.describe ApplicationSettings::UpdateService do ...@@ -234,16 +234,6 @@ RSpec.describe ApplicationSettings::UpdateService do
include_examples 'worker is called' include_examples 'worker is called'
end end
end end
context 'when feature is disabled' do
let(:opts) { { new_user_signups_cap: 10 } }
before do
stub_feature_flags(admin_new_user_signups_cap: false)
end
include_examples 'worker is not called'
end
end end
end end
end end
...@@ -110,18 +110,6 @@ RSpec.describe Users::BuildService do ...@@ -110,18 +110,6 @@ RSpec.describe Users::BuildService do
expect(user).to be_active expect(user).to be_active
end end
end end
context 'when feature is disabled' do
before do
stub_feature_flags(admin_new_user_signups_cap: false)
end
it 'does not set the user state to blocked_pending_approval' do
user = service.execute
expect(user).to be_active
end
end
end 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