FEATURE: allow plugins to extend Groups (#14216)

* add_permitted_group_param API for plugins
* add groups-interaction-custom-options outlet
* custom search can use custom group scope
This commit is contained in:
Krzysztof Kotlarek
2021-09-06 10:18:51 +10:00
committed by GitHub
parent 9873a942e3
commit f859fd6bde
11 changed files with 78 additions and 3 deletions

View File

@@ -920,6 +920,7 @@ describe Group do
describe '.search_groups' do
fab!(:group) { Fabricate(:group, name: 'tEsT_more_things', full_name: 'Abc something awesome') }
let(:messageable_group) { Fabricate(:group, name: "MessageableGroup", messageable_level: Group::ALIAS_LEVELS[:everyone]) }
it 'should return the right groups' do
group
@@ -934,6 +935,18 @@ describe Group do
expect(Group.search_groups('sOmEthi')).to eq([group])
expect(Group.search_groups('test2')).to eq([])
end
it 'allows to filter with additional scope' do
messageable_group
expect(Group.search_groups('es', custom_scope: { name: :messageable, arguments: [user] }).sort).to eq([messageable_group, group].sort)
plugin = Plugin::Instance.new
plugin.register_group_scope_for_search(:messageable)
expect(Group.search_groups('es', custom_scope: { name: :messageable, arguments: [user] }).sort).to eq([messageable_group].sort)
DiscoursePluginRegistry.reset!
end
end
describe '#bulk_add' do