aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2018-02-23 00:08:15 +0200
committerbogdanvlviv <bogdanvlviv@gmail.com>2018-02-23 01:23:59 +0200
commit9390bff5ce5fcde82840747fae077ba333375211 (patch)
treea68e8dd311d80c43640849473539b15764314d84 /railties/test
parentdcdb8e72cc2c4e57334e0de94f516e53ff028de8 (diff)
downloadrails-9390bff5ce5fcde82840747fae077ba333375211.tar.gz
rails-9390bff5ce5fcde82840747fae077ba333375211.tar.bz2
rails-9390bff5ce5fcde82840747fae077ba333375211.zip
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.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/generators/plugin_generator_test.rb9
1 files changed, 9 insertions, 0 deletions
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 "<title>Bukkits</title>", 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)