diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 5ddeb9630baa68109dca77a5101e495cfc16a2d3..7960e5d64d0c509aa4e672a13c9d8c8d854902c2 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -208,7 +208,10 @@ def application_setting_params params[:application_setting][:import_sources]&.delete("") params[:application_setting][:restricted_visibility_levels]&.delete("") - params[:application_setting][:required_instance_ci_template] = nil if params[:application_setting][:required_instance_ci_template].blank? + + if params[:application_setting].key?(:required_instance_ci_template) + params[:application_setting][:required_instance_ci_template] = nil if params[:application_setting][:required_instance_ci_template].empty? + end remove_blank_params_for!(:elasticsearch_aws_secret_access_key, :eks_secret_access_key) @@ -217,9 +220,7 @@ def application_setting_params params.delete(:domain_denylist_raw) if params[:domain_denylist] params.delete(:domain_allowlist_raw) if params[:domain_allowlist] - params.require(:application_setting).permit( - visible_application_setting_attributes - ) + params[:application_setting].permit(visible_application_setting_attributes) end def recheck_user_consent? diff --git a/ee/spec/controllers/admin/application_settings_controller_spec.rb b/ee/spec/controllers/admin/application_settings_controller_spec.rb index d4f70a6ceb197f6434f7cbb346a0b257bb2df7ae..ac4e33e5918bbe1a812687786e358994fef12f46 100644 --- a/ee/spec/controllers/admin/application_settings_controller_spec.rb +++ b/ee/spec/controllers/admin/application_settings_controller_spec.rb @@ -194,6 +194,14 @@ expect(ApplicationSetting.current.required_instance_ci_template).to be_nil end end + + context 'without key' do + it 'does not set required_instance_ci_template to nil' do + put :update, params: { application_setting: {} } + + expect(ApplicationSetting.current.required_instance_ci_template).to be == 'Auto-DevOps' + end + end end end