mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:52:11 +08:00
FIX: Do not load plugin CSS/JS assets when disabled (#8275)
Follow-up to839916aa49
and5bd6b70d98
This commit is contained in:
parent
72aa26c8c5
commit
4312bbe1e7
|
@ -216,7 +216,7 @@ module Discourse
|
|||
plugins.select do |plugin|
|
||||
next if args[:include_official] == false && plugin.metadata.official?
|
||||
next if args[:include_unofficial] == false && !plugin.metadata.official?
|
||||
next if args[:include_disabled] == false && !plugin.enabled?
|
||||
next if !args[:include_disabled] && !plugin.enabled?
|
||||
|
||||
true
|
||||
end
|
||||
|
|
|
@ -65,6 +65,33 @@ describe Discourse do
|
|||
end
|
||||
end
|
||||
|
||||
context 'plugins' do
|
||||
let(:plugin_class) do
|
||||
Class.new(Plugin::Instance) do
|
||||
attr_accessor :enabled
|
||||
def enabled?
|
||||
@enabled
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:plugin1) { plugin_class.new.tap { |p| p.enabled = true } }
|
||||
let(:plugin2) { plugin_class.new.tap { |p| p.enabled = false } }
|
||||
|
||||
before { Discourse.plugins.append(plugin1, plugin2) }
|
||||
after { Discourse.plugins.clear }
|
||||
|
||||
it 'can find plugins correctly' do
|
||||
expect(Discourse.plugins).to contain_exactly(plugin1, plugin2)
|
||||
|
||||
# Exclude disabled plugins by default
|
||||
expect(Discourse.find_plugins({})).to contain_exactly(plugin1)
|
||||
|
||||
# Include disabled plugins when requested
|
||||
expect(Discourse.find_plugins(include_disabled: true)).to contain_exactly(plugin1, plugin2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'authenticators' do
|
||||
it 'returns inbuilt authenticators' do
|
||||
expect(Discourse.authenticators).to match_array(Discourse::BUILTIN_AUTH.map(&:authenticator))
|
||||
|
|
Loading…
Reference in New Issue
Block a user