mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
DEV: Move about_stat_groups to DiscoursePluginRegistry (#20496)
Follow up to 098ab29d4150a5a39880d59ef6cad5f6795a18fd. Since we just used a `cattr_reader` on `About` this was not safe for multisite, since some sites could have the chat plugin enabled and some may not. Using `DiscoursePluginRegistry` gets around this issue, and makes it so the chat stats only show for a site if `chat_enabled` is true.
This commit is contained in:
@ -769,7 +769,7 @@ RSpec.describe Plugin::Instance do
|
||||
describe "#register_about_stat_group" do
|
||||
let(:plugin) { Plugin::Instance.new }
|
||||
|
||||
after { About.clear_plugin_stat_groups }
|
||||
after { DiscoursePluginRegistry.reset! }
|
||||
|
||||
it "registers an about stat group correctly" do
|
||||
stats = { :last_day => 1, "7_days" => 10, "30_days" => 100, :count => 1000 }
|
||||
@ -789,6 +789,13 @@ RSpec.describe Plugin::Instance do
|
||||
plugin.register_about_stat_group("some_group") { stats }
|
||||
expect(About.displayed_plugin_stat_groups).to eq([])
|
||||
end
|
||||
|
||||
it "does not allow duplicate named stat groups" do
|
||||
stats = { :last_day => 1, "7_days" => 10, "30_days" => 100, :count => 1000 }
|
||||
plugin.register_about_stat_group("some_group") { stats }
|
||||
plugin.register_about_stat_group("some_group") { stats }
|
||||
expect(DiscoursePluginRegistry.about_stat_groups.count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#register_user_destroyer_on_content_deletion_callback" do
|
||||
|
Reference in New Issue
Block a user