Avoid deprecated site setting logging in `SiteSetting.settings_hash`.

This commit is contained in:
Guo Xiang Tan 2018-11-20 11:59:38 +08:00
parent 81b3bdaabd
commit 1a57be3248
3 changed files with 16 additions and 8 deletions

View File

@ -177,9 +177,17 @@ module SiteSettingExtension
def settings_hash
result = {}
deprecated_settings = SiteSettings::DeprecatedSettings::SETTINGS.map { |s| s[0] }
defaults.all.keys.each do |s|
result[s] = send(s).to_s
result[s] =
if deprecated_settings.include?(s.to_s)
send(s, warn: false).to_s
else
send(s).to_s
end
end
result
end

View File

@ -1,7 +1,7 @@
module SiteSettings; end
module SiteSettings::DeprecatedSettings
DEPRECATED_SETTINGS = [
SETTINGS = [
['logo_url', 'logo', false, '2.4'],
['logo_small_url', 'logo_small', false, '2.4'],
['digest_logo_url', 'digest_logo', false, '2.4'],
@ -15,7 +15,7 @@ module SiteSettings::DeprecatedSettings
]
def setup_deprecated_methods
DEPRECATED_SETTINGS.each do |old_setting, new_setting, override, version|
SETTINGS.each do |old_setting, new_setting, override, version|
unless override
SiteSetting.singleton_class.public_send(
:alias_method, :"_#{old_setting}", :"#{old_setting}"

View File

@ -163,10 +163,10 @@ describe SiteSetting do
it 'should act as a proxy to the new methods' do
begin
original_settings = SiteSettings::DeprecatedSettings::DEPRECATED_SETTINGS
SiteSettings::DeprecatedSettings::DEPRECATED_SETTINGS.clear
original_settings = SiteSettings::DeprecatedSettings::SETTINGS
SiteSettings::DeprecatedSettings::SETTINGS.clear
SiteSettings::DeprecatedSettings::DEPRECATED_SETTINGS.push([
SiteSettings::DeprecatedSettings::SETTINGS.push([
'use_https', 'force_https', true, '0.0.1'
])
@ -186,9 +186,9 @@ describe SiteSetting do
expect(SiteSetting.force_https).to eq(false)
expect(SiteSetting.force_https?).to eq(false)
ensure
SiteSettings::DeprecatedSettings::DEPRECATED_SETTINGS.clear
SiteSettings::DeprecatedSettings::SETTINGS.clear
SiteSettings::DeprecatedSettings::DEPRECATED_SETTINGS.concat(
SiteSettings::DeprecatedSettings::SETTINGS.concat(
original_settings
)
end