1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Nudge engines to be compatible with include_all_helpers

When applications use this configuration setting, it may break an Engine
relying implicitly on all helpers being included.

By setting the option in the dummy app, we help engine authors be
compatible with this setting.

Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
This commit is contained in:
Étienne Barrié 2021-03-09 16:26:13 -05:00
parent dc7817cb42
commit d5b8b66b8a
2 changed files with 35 additions and 0 deletions

View file

@ -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

View file

@ -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