DEV: Add framework for filtered plugin registers (#9763)

* DEV: Add framework for filtered plugin registers

Plugins often need to add values to a list, and we need to filter those lists at runtime to ignore values from disabled plugins. This commit provides a re-usable way to do that, which should make it easier to add new registers in future, and also reduce repeated code.

Follow-up commits will migrate existing registers to use this new system

* DEV: Migrate user and group custom field APIs to plugin registry

This gives us a consistent system for checking plugin enabled state, so we are repeating less logic. API changes are backwards compatible
This commit is contained in:
David Taylor
2020-05-15 14:04:38 +01:00
committed by GitHub
parent 0495a748d0
commit 461b4e5cc6
12 changed files with 111 additions and 78 deletions

View File

@ -46,7 +46,7 @@ RSpec.describe Admin::GroupsController do
end
after do
Group.plugin_editable_group_custom_fields.clear
DiscoursePluginRegistry.reset!
end
it "only updates allowed user fields" do
@ -63,7 +63,7 @@ RSpec.describe Admin::GroupsController do
end
it "is secure when there are no registered editable fields" do
Group.plugin_editable_group_custom_fields.clear
DiscoursePluginRegistry.reset!
params = group_params
params[:group].merge!(custom_fields: { test: :hello1, test2: :hello2 })