diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index acdd5c6f28..695da954dd 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -141,6 +141,13 @@ module Rails if mountable? template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true end + if engine? && !api? + insert_into_file "#{dummy_path}/config/application.rb", indent(<<~RUBY, 4), after: /^\s*config\.load_defaults.*\n/ + + # For compatibility with applications that use this config + config.action_controller.include_all_helpers = false + RUBY + end end def test_dummy_webpacker_assets diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb index 5a10cf1e32..05998819dc 100644 --- a/railties/test/generators/plugin_generator_test.rb +++ b/railties/test/generators/plugin_generator_test.rb @@ -591,6 +591,34 @@ class PluginGeneratorTest < Rails::Generators::TestCase assert_file "test/dummy/config/application.rb", /^require "bukkits"/ end + def test_dummy_application_sets_include_all_helpers_to_false_for_mountable + run_generator [destination_root, "--mountable"] + + assert_file "test/dummy/config/application.rb", /^ config\.action_controller\.include_all_helpers = false$/ + end + + def test_dummy_application_sets_include_all_helpers_to_false_for_full + run_generator [destination_root, "--full"] + + assert_file "test/dummy/config/application.rb", /include_all_helpers/ + end + + def test_dummy_application_does_not_set_include_all_helpers_for_regular + run_generator + + assert_file "test/dummy/config/application.rb" do |content| + assert_no_match(/include_all_helpers/, content) + end + end + + def test_dummy_application_does_not_set_include_all_helpers_for_api + run_generator [destination_root, "--mountable", "--api"] + + assert_file "test/dummy/config/application.rb" do |content| + assert_no_match(/include_all_helpers/, content) + end + end + def test_dummy_application_uses_dynamic_rails_version_number run_generator