From 9390bff5ce5fcde82840747fae077ba333375211 Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Fri, 23 Feb 2018 00:08:15 +0200 Subject: Improve generated file `app/views/application.html.erb` of plugin - Do not generate `javascript_include_tag` if `--skip-javascript` - Generate `<%= csp_meta_tag %>`. Related to #32018. --- railties/test/generators/plugin_generator_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'railties/test') diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index f3b9e0204e..fba090c004 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -218,11 +218,17 @@ 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/views/layouts/bukkits/application.html.erb" do |content| + assert_match "javascript_include_tag", content + end end def test_skip_javascripts run_generator [destination_root, "--skip-javascript", "--mountable"] assert_no_file "app/assets/javascripts/bukkits/application.js" + assert_file "app/views/layouts/bukkits/application.html.erb" do |content| + assert_no_match "javascript_include_tag", content + end end def test_template_from_dir_pwd @@ -321,8 +327,11 @@ class PluginGeneratorTest < Rails::Generators::TestCase assert_file "app/helpers/bukkits/application_helper.rb", /module Bukkits\n module ApplicationHelper/ assert_file "app/views/layouts/bukkits/application.html.erb" do |contents| assert_match "Bukkits", contents + assert_match "<%= csrf_meta_tags %>", contents + assert_match "<%= csp_meta_tag %>", contents assert_match(/stylesheet_link_tag\s+['"]bukkits\/application['"]/, contents) assert_match(/javascript_include_tag\s+['"]bukkits\/application['"]/, contents) + assert_match "<%= yield %>", contents end assert_file "test/test_helper.rb" do |content| assert_match(/ActiveRecord::Migrator\.migrations_paths.+\.\.\/test\/dummy\/db\/migrate/, content) -- cgit v1.2.3