Add specs to hidding settings when shadowed by a global.

This commit is contained in:
Guo Xiang Tan 2016-08-11 16:04:45 +08:00
parent 11afb20772
commit 6075debc90
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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