Commit 2d93501b authored by Michael Kozono's avatar Michael Kozono

Merge branch 'ag-remove-message-when-maintenance-mode-is-disabled' into 'master'

Remove maintenance mode message when it mode is disabled

See merge request gitlab-org/gitlab!50451
parents 639245d7 99e97ba5
......@@ -12,6 +12,10 @@ module EE
limit = params.delete(:repository_size_limit)
application_setting.repository_size_limit = ::Gitlab::Utils.try_megabytes_to_bytes(limit) if limit
if params[:maintenance_mode] == false || params[:maintenance_mode_message] == ''
params[:maintenance_mode_message] = nil
end
elasticsearch_namespace_ids = params.delete(:elasticsearch_namespace_ids)
elasticsearch_project_ids = params.delete(:elasticsearch_project_ids)
......
......@@ -269,6 +269,58 @@ RSpec.describe Admin::ApplicationSettingsController do
expect(response).to redirect_to(general_admin_application_settings_path)
expect(ApplicationSetting.current.enforce_pat_expiration).to be_falsey
end
context 'maintenance mode settings' do
let(:message) { 'Maintenance mode is on.' }
before do
stub_licensed_features(geo: true)
end
it "updates maintenance_mode setting" do
put :update, params: { application_setting: { maintenance_mode: true } }
expect(response).to redirect_to(general_admin_application_settings_path)
expect(ApplicationSetting.current.maintenance_mode).to be_truthy
end
it "updates maintenance_mode_message setting" do
put :update, params: { application_setting: { maintenance_mode_message: message } }
expect(response).to redirect_to(general_admin_application_settings_path)
expect(ApplicationSetting.current.maintenance_mode_message).to eq(message)
end
context 'when update disables maintenance mode' do
it 'removes maintenance_mode_message setting' do
put :update, params: { application_setting: { maintenance_mode: false } }
expect(response).to redirect_to(general_admin_application_settings_path)
expect(ApplicationSetting.current.maintenance_mode).to be_falsy
expect(ApplicationSetting.current.maintenance_mode_message).to be_nil
end
end
context 'when update does not disable maintenance mode' do
it 'does not remove maintenance_mode_message' do
set_maintenance_mode(message)
put :update, params: { application_setting: {} }
expect(ApplicationSetting.current.maintenance_mode_message).to eq(message)
end
end
context 'when updating maintenance_mode_message with empty string' do
it 'removes maintenance_mode_message' do
set_maintenance_mode(message)
put :update, params: { application_setting: { maintenance_mode_message: '' } }
expect(ApplicationSetting.current.maintenance_mode_message).to eq(nil)
end
end
end
end
describe 'GET #seat_link_payload' do
......@@ -324,4 +376,11 @@ RSpec.describe Admin::ApplicationSettingsController do
end
end
end
def set_maintenance_mode(message)
ApplicationSetting.current.update!(
maintenance_mode: true,
maintenance_mode_message: message
)
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