From 6be956339cba656700f18ff4729f42c9fb5b1b4c Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Fri, 2 Jul 2021 12:40:50 -0300 Subject: [PATCH] DEV: Tests can reset a single registry (#13618) Plugins can use this method to reset their specific registries without touching the ones defined in core. --- lib/discourse_plugin_registry.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rb index 840b038977f..097db834c55 100644 --- a/lib/discourse_plugin_registry.rb +++ b/lib/discourse_plugin_registry.rb @@ -227,4 +227,11 @@ class DiscoursePluginRegistry end end + def self.reset_register!(register_name) + found_register = @@register_names.detect { |name| name == register_name } + + if found_register + instance_variable_set(:"@#{found_register}", nil) + end + end end