DEV: Support setting deprecated site settings via the API (#12172)

This commit is contained in:
David Taylor 2021-02-22 18:10:54 +00:00 committed by GitHub
parent 0620f6298e
commit 8cd7c9b259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -14,6 +14,12 @@ class Admin::SiteSettingsController < Admin::AdminController
id = params[:id]
value = params[id]
value.strip! if value.is_a?(String)
new_setting_name = SiteSettings::DeprecatedSettings::SETTINGS.find do |old_name, new_name, _, _|
break new_name if old_name == id
end
id = new_setting_name if new_setting_name
raise_access_hidden_setting(id)
if SiteSetting.type_supervisor.get_type(id) == :uploaded_image_list

View File

@ -45,6 +45,14 @@ describe Admin::SiteSettingsController do
expect(SiteSetting.test_setting).to eq('hello')
end
it 'works for deprecated settings' do
put "/admin/site_settings/sso_url.json", params: {
sso_url: "https://example.com"
}
expect(response.status).to eq(200)
expect(SiteSetting.discourse_connect_url).to eq("https://example.com")
end
it 'allows value to be a blank string' do
put "/admin/site_settings/test_setting.json", params: {
test_setting: ''