diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb index c8fc3288155..65ee570e8d1 100644 --- a/lib/site_setting_extension.rb +++ b/lib/site_setting_extension.rb @@ -119,6 +119,7 @@ module SiteSettingExtension if opts[:shadowed_by_global] && GlobalSetting.respond_to?(name) val = GlobalSetting.send(name) + unless val.nil? || (val == ''.freeze) hidden_settings << name shadowed_settings << name diff --git a/spec/components/site_setting_extension_spec.rb b/spec/components/site_setting_extension_spec.rb index f6982e8ef0c..e981f4fbf72 100644 --- a/spec/components/site_setting_extension_spec.rb +++ b/spec/components/site_setting_extension_spec.rb @@ -498,6 +498,17 @@ describe SiteSettingExtension do expect(settings.trout_api_key).to eq('purringcat') end + it "should add the key to the hidden_settings collection" do + expect(settings.hidden_settings.include?(:trout_api_key)).to eq(true) + + ['', nil].each_with_index do |setting, index| + GlobalSetting.stubs(:"trout_api_key_#{index}").returns(setting) + settings.setting(:"trout_api_key_#{index}", 'evil', shadowed_by_global: true) + settings.refresh! + expect(settings.hidden_settings.include?(:"trout_api_key_#{index}")).to eq(false) + end + end + it "should add the key to the shadowed_settings collection" do expect(settings.shadowed_settings.include?(:trout_api_key)).to eq(true) end