From ab63420233e124a6f04b76d5bc848d11ba28689c Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Fri, 23 Feb 2018 23:03:50 +0200 Subject: [PATCH] Improve generated file `app/assets/javascripts/application.js` of plugin Add `//= require rails-ujs` Closes #32094 --- .../rails/plugin/templates/rails/javascripts.js.tt | 1 + railties/test/generators/plugin_generator_test.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt index f3d80c87f5..51049826bf 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt @@ -10,6 +10,7 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // +//= require rails-ujs <% unless skip_active_storage? -%> //= require activestorage <% end -%> diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index fba090c004..28ac3611b7 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -217,7 +217,11 @@ class PluginGeneratorTest < Rails::Generators::TestCase def test_javascripts_generation run_generator [destination_root, "--mountable"] - assert_file "app/assets/javascripts/bukkits/application.js" + assert_file "app/assets/javascripts/bukkits/application.js" do |content| + assert_match "//= require rails-ujs", content + assert_match "//= require activestorage", content + assert_match "//= require_tree .", content + end assert_file "app/views/layouts/bukkits/application.html.erb" do |content| assert_match "javascript_include_tag", content end