FIX: Do not load plugin CSS/JS assets when disabled (#8275)

Follow-up to 839916aa49 and 5bd6b70d98
This commit is contained in:
David Taylor 2019-11-01 09:50:31 +00:00 committed by GitHub
parent 72aa26c8c5
commit 4312bbe1e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -216,7 +216,7 @@ module Discourse
plugins.select do |plugin| plugins.select do |plugin|
next if args[:include_official] == false && plugin.metadata.official? next if args[:include_official] == false && plugin.metadata.official?
next if args[:include_unofficial] == 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 true
end end

View File

@ -65,6 +65,33 @@ describe Discourse do
end end
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 context 'authenticators' do
it 'returns inbuilt authenticators' do it 'returns inbuilt authenticators' do
expect(Discourse.authenticators).to match_array(Discourse::BUILTIN_AUTH.map(&:authenticator)) expect(Discourse.authenticators).to match_array(Discourse::BUILTIN_AUTH.map(&:authenticator))