FIX: false overrides should be permitted via ENV

This commit is contained in:
Sam 2016-02-13 17:49:26 +11:00
parent 3939b9ec7d
commit b1e68390f4
2 changed files with 13 additions and 1 deletions

View File

@ -121,7 +121,7 @@ module SiteSettingExtension
# exists it will be used instead of the setting and the setting will be hidden. # exists it will be used instead of the setting and the setting will be hidden.
# Useful for things like API keys on multisite. # Useful for things like API keys on multisite.
if opts[:shadowed_by_global] && GlobalSetting.respond_to?(name) if opts[:shadowed_by_global] && GlobalSetting.respond_to?(name)
if (val = GlobalSetting.send(name)).present? unless (val = GlobalSetting.send(name)) == ''.freeze
hidden_settings << name hidden_settings << name
shadowed_settings << name shadowed_settings << name
current_value = val current_value = val

View File

@ -470,6 +470,18 @@ describe SiteSettingExtension do
end end
end end
context "with a false override" do
before do
GlobalSetting.stubs(:bool).returns(false)
settings.setting(:bool, true, shadowed_by_global: true)
settings.refresh!
end
it "should return default cause nothing is set" do
expect(settings.bool).to eq(false)
end
end
context "with global setting" do context "with global setting" do
before do before do
GlobalSetting.stubs(:trout_api_key).returns('purringcat') GlobalSetting.stubs(:trout_api_key).returns('purringcat')