discourse/spec/lib/site_settings/hidden_provider_spec.rb
Neil Lalonde 5dae0fdfb6
DEV: add a plugin modifier to change hidden site settings (#24160)
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
```
2023-10-31 10:09:51 -04:00

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