Commit f7e0c562 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Fix validations for user cap setting

parent d99701be
......@@ -95,11 +95,15 @@ module EE
validate :allowed_frameworks, if: :compliance_frameworks_changed?
validates :new_user_signups_cap,
numericality: { only_integer: true,
allow_nil: true,
greater_than: 0 }
allow_blank: true,
numericality: { only_integer: true, greater_than: 0 }
validates :new_user_signups_cap,
numericality: { less_than_or_equal_to: proc { License.current&.restricted_user_count } },
allow_blank: true,
numericality: {
only_integer: true,
greater_than: 0,
less_than_or_equal_to: proc { License.current&.restricted_user_count }
},
if: proc { License.current&.restricted_user_count? }
after_commit :update_personal_access_tokens_lifetime, if: :saved_change_to_max_personal_access_token_lifetime?
......
......@@ -88,6 +88,8 @@ RSpec.describe ApplicationSetting do
it { is_expected.to allow_value(nil).for(:new_user_signups_cap) }
it { is_expected.to allow_value(1).for(:new_user_signups_cap) }
it { is_expected.to allow_value(10).for(:new_user_signups_cap) }
it { is_expected.to allow_value("").for(:new_user_signups_cap) }
it { is_expected.not_to allow_value("value").for(:new_user_signups_cap) }
it { is_expected.not_to allow_value(-1).for(:new_user_signups_cap) }
it { is_expected.not_to allow_value(2.5).for(:new_user_signups_cap) }
......@@ -175,6 +177,7 @@ RSpec.describe ApplicationSetting do
it { is_expected.to allow_value(max_active_user_count - 1).for(:new_user_signups_cap) }
it { is_expected.to allow_value(max_active_user_count).for(:new_user_signups_cap) }
it { is_expected.to allow_value(nil).for(:new_user_signups_cap) }
it { is_expected.not_to allow_value(max_active_user_count + 1).for(:new_user_signups_cap) }
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