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

This commit is contained in:
Mark VanLandingham 2021-06-17 11:50:47 -05:00 committed by GitHub
parent 854d965679
commit 6fd13f38a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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')