aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-02-23 16:59:26 -0500
committerGitHub <noreply@github.com>2018-02-23 16:59:26 -0500
commit222f90549a30d5a42091708ddbbda7cdba0cb132 (patch)
treeb958ca6bd7e1658a3ae3e93f4b6b5dfb7597b5ab
parent1077ae96b34b5a1dfbf10ee0c40b1ceb1eb6b30b (diff)
parentab63420233e124a6f04b76d5bc848d11ba28689c (diff)
downloadrails-222f90549a30d5a42091708ddbbda7cdba0cb132.tar.gz
rails-222f90549a30d5a42091708ddbbda7cdba0cb132.tar.bz2
rails-222f90549a30d5a42091708ddbbda7cdba0cb132.zip
Merge pull request #32095 from bogdanvlviv/require_rails-ujs-in-generated-engine
Improve generated file `app/assets/javascripts/application.js` of plugin
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js.tt1
-rw-r--r--railties/test/generators/plugin_generator_test.rb6
2 files changed, 6 insertions, 1 deletions
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