diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 362bc59f3b1..eef8d5ba2ea 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -283,6 +283,7 @@ class Plugin::Instance Rails.configuration.assets.paths << auto_generated_path Rails.configuration.assets.paths << File.dirname(path) + "/assets" Rails.configuration.assets.paths << File.dirname(path) + "/admin/assets" + Rails.configuration.assets.paths << File.dirname(path) + "/test/javascripts" # Automatically include rake tasks Rake.add_rakelib(File.dirname(path) + "/lib/tasks") diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6 index d03b07814ff..0b6f555294f 100644 --- a/test/javascripts/helpers/create-pretender.js.es6 +++ b/test/javascripts/helpers/create-pretender.js.es6 @@ -77,6 +77,8 @@ export default function() { } }); + this.get('/admin/plugins', () => { return response({ plugins: [] }); }); + this.get('/composer-messages', () => { return response([]); }); this.get("/latest.json", () => { diff --git a/test/javascripts/plugin_tests.js.erb b/test/javascripts/plugin_tests.js.erb new file mode 100644 index 00000000000..a7b2f9a36d9 --- /dev/null +++ b/test/javascripts/plugin_tests.js.erb @@ -0,0 +1,19 @@ +<% + DiscoursePluginRegistry.javascripts.each { |js| require_asset(js) } + DiscoursePluginRegistry.handlebars.each { |hb| require_asset(hb) } + DiscoursePluginRegistry.each_globbed_asset do |f, ext| + if File.directory?(f) + depend_on(f) + elsif f.to_s.end_with?(".#{ext}") + require_asset(f) + end + end + + Discourse.plugins.each do |p| + root_path = "#{File.dirname(p.path)}/test/javascripts" + + Dir.glob(root_path + '/**/**.es6').each do |f| + require_asset(f) + end + end +%> diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js index a7191147d29..08de7fdce37 100644 --- a/test/javascripts/test_helper.js +++ b/test/javascripts/test_helper.js @@ -43,6 +43,7 @@ //= require_tree ./fixtures //= require_tree ./lib //= require_tree . +//= require plugin_tests //= require_self // //= require ../../public/javascripts/jquery.magnific-popup-min.js