Commit 7596dd3d authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'nicolasdular/namespace-limit-setting-backend' into 'master'

Accept namespace limit in application settings

See merge request gitlab-org/gitlab!28045
parents a0462025 33def370
......@@ -217,6 +217,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:lets_encrypt_terms_of_service_accepted,
:domain_blacklist_file,
:raw_blob_request_limit,
:namespace_storage_size_limit,
disabled_oauth_sign_in_sources: [],
import_sources: [],
repository_storages: [],
......
......@@ -337,6 +337,10 @@ class ApplicationSetting < ApplicationRecord
length: { maximum: 255 },
allow_blank: true
validates :namespace_storage_size_limit,
presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
attr_encrypted :asset_proxy_secret_key,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
......
......@@ -111,6 +111,7 @@ module ApplicationSettingImplementation
sourcegraph_url: nil,
sourcegraph_public_only: true,
minimum_password_length: DEFAULT_MINIMUM_PASSWORD_LENGTH,
namespace_storage_size_limit: 0,
terminal_max_session_time: 0,
throttle_authenticated_api_enabled: false,
throttle_authenticated_api_period_in_seconds: 3600,
......
......@@ -104,6 +104,22 @@ describe Admin::ApplicationSettingsController do
expect(ApplicationSetting.current.minimum_password_length).to eq(10)
end
it 'updates namespace_storage_size_limit setting' do
put :update, params: { application_setting: { namespace_storage_size_limit: '100' } }
expect(response).to redirect_to(general_admin_application_settings_path)
expect(response).to set_flash[:notice].to('Application settings saved successfully')
expect(ApplicationSetting.current.namespace_storage_size_limit).to eq(100)
end
it 'does not accept an invalid namespace_storage_size_limit' do
put :update, params: { application_setting: { namespace_storage_size_limit: '-100' } }
expect(response).to render_template(:general)
expect(assigns(:application_setting).errors[:namespace_storage_size_limit]).to be_present
expect(ApplicationSetting.current.namespace_storage_size_limit).not_to eq(-100)
end
context 'external policy classification settings' do
let(:settings) do
{
......
......@@ -82,6 +82,11 @@ describe ApplicationSetting do
it { is_expected.not_to allow_value('abc').for(:minimum_password_length) }
it { is_expected.to allow_value(10).for(:minimum_password_length) }
it { is_expected.to allow_value(0).for(:namespace_storage_size_limit) }
it { is_expected.to allow_value(1).for(:namespace_storage_size_limit) }
it { is_expected.not_to allow_value(nil).for(:namespace_storage_size_limit) }
it { is_expected.not_to allow_value(-1).for(:namespace_storage_size_limit) }
context 'grafana_url validations' do
before do
subject.instance_variable_set(:@parsed_grafana_url, nil)
......
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