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

Merge pull request #41643 from etiennebarrie/engine-include_all_helpers

Nudge engines to be compatible with include_all_helpers
This commit is contained in:
Rafael França 2021-06-08 16:45:09 -04:00 committed by GitHub
commit dea7938376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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