DEV: reset plugin added directory columns in testing (#13420)

DEV: reset plugin added directory columns in testing (#13420)

diff --git a/app/models/directory_column.rb b/app/models/directory_column.rb
index cdcfe92..9a873af 100644
--- a/app/models/directory_column.rb
+++ b/app/models/directory_column.rb
@@ -30,4 +30,8 @@ class DirectoryColumn < ActiveRecord::Base
   def self.plugin_directory_columns
     @@plugin_directory_columns
   end
+
+  def self.clear_plugin_directory_columns
+    @@plugin_directory_columns = []
+  end
 end
diff --git a/app/models/directory_item.rb b/app/models/directory_item.rb
index 3c78dcb..c17c83c 100644
--- a/app/models/directory_item.rb
+++ b/app/models/directory_item.rb
@@ -34,6 +34,10 @@ class DirectoryItem < ActiveRecord::Base
     @@plugin_queries
   end
 
+  def self.clear_plugin_queries
+    @@plugin_queries = []
+  end
+
   def self.refresh_period!(period_type, force: false)
 
     Discourse.redis.set("directory_#{period_types[period_type]}", Time.zone.now.to_i)
diff --git a/spec/components/plugin/instance_spec.rb b/spec/components/plugin/instance_spec.rb
index 4f2880e..50d7d92 100644
--- a/spec/components/plugin/instance_spec.rb
+++ b/spec/components/plugin/instance_spec.rb
@@ -604,6 +604,11 @@ describe Plugin::Instance do
   describe '#add_directory_column' do
     let!(:plugin) { Plugin::Instance.new }
 
+    after do
+      DirectoryItem.clear_plugin_queries
+      DirectoryColumn.clear_plugin_directory_columns
+    end
+
     it 'creates a directory column record' do
       plugin.add_directory_column('random_c', query: "SELECT COUNT(*) FROM users", icon: 'recycle')
 

GitHub sha: 6fd13f38a2ec3597aeb269643fe51277b52a5fd5

This commit appears in #13420 which was approved by davidtaylorhq. It was merged by markvanlan.