This reverts commit ddcee84e45
.
This commit is contained in:
parent
ddcee84e45
commit
bd7cea7dd7
|
@ -91,12 +91,8 @@ module SiteSettingExtension
|
|||
@shadowed_settings ||= []
|
||||
end
|
||||
|
||||
def hidden_settings_provider
|
||||
@hidden_settings_provider ||= SiteSettings::HiddenProvider.new
|
||||
end
|
||||
|
||||
def hidden_settings
|
||||
hidden_settings_provider.all
|
||||
@hidden_settings ||= []
|
||||
end
|
||||
|
||||
def refresh_settings
|
||||
|
@ -588,14 +584,14 @@ module SiteSettingExtension
|
|||
|
||||
categories[name] = opts[:category] || :uncategorized
|
||||
|
||||
hidden_settings_provider.add_hidden(name) if opts[:hidden]
|
||||
hidden_settings << name if opts[:hidden]
|
||||
|
||||
if GlobalSetting.respond_to?(name)
|
||||
val = GlobalSetting.public_send(name)
|
||||
|
||||
unless val.nil? || (val == "")
|
||||
shadowed_val = val
|
||||
hidden_settings_provider.add_hidden(name)
|
||||
hidden_settings << name
|
||||
shadowed_settings << name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module SiteSettings
|
||||
end
|
||||
|
||||
# A class to store and modify hidden site settings
|
||||
class SiteSettings::HiddenProvider
|
||||
def initialize
|
||||
@hidden_settings = Set.new
|
||||
end
|
||||
|
||||
def add_hidden(site_setting_name)
|
||||
@hidden_settings << site_setting_name
|
||||
end
|
||||
|
||||
def all
|
||||
DiscoursePluginRegistry.apply_modifier(:hidden_site_settings, @hidden_settings)
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe SiteSettings::HiddenProvider do
|
||||
let(:provider_local) { SiteSettings::LocalProcessProvider.new }
|
||||
let(:settings) { new_settings(provider_local) }
|
||||
let(:hidden_provider) { SiteSettings::HiddenProvider.new }
|
||||
|
||||
describe "all" do
|
||||
after { DiscoursePluginRegistry.clear_modifiers! }
|
||||
|
||||
it "can return defaults" do
|
||||
hidden_provider.add_hidden(:secret_setting)
|
||||
hidden_provider.add_hidden(:internal_thing)
|
||||
expect(hidden_provider.all).to contain_exactly(:secret_setting, :internal_thing)
|
||||
end
|
||||
|
||||
it "can return results from modifiers" do
|
||||
hidden_provider.add_hidden(:secret_setting)
|
||||
plugin = Plugin::Instance.new
|
||||
plugin.register_modifier(:hidden_site_settings) { |defaults| defaults + [:other_setting] }
|
||||
expect(hidden_provider.all).to contain_exactly(:secret_setting, :other_setting)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue