mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 23:33:37 +08:00
5dae0fdfb6
Plugins can use a new modifier to change which site settings are hidden using the :hidden_site_settings modifier. For example: ``` register_modifier(:hidden_site_settings) do |hidden| (hidden + [:invite_only, :login_required]).uniq end ```
25 lines
893 B
Ruby
25 lines
893 B
Ruby
# 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
|