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

generate config.cache_classes = false if Spring

This commit is contained in:
Xavier Noria 2019-04-14 23:06:32 +02:00
parent 1e4b959c5e
commit 65344f254c
3 changed files with 21 additions and 5 deletions

View file

@ -1,3 +1,8 @@
* New applications get `config.cache_classes = false` in `config/environments/test.rb`
unless `--skip-spring`.
*Xavier Noria*
* Autoloading during initialization is deprecated. * Autoloading during initialization is deprecated.
*Xavier Noria* *Xavier Noria*

View file

@ -1,11 +1,16 @@
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
<%# Spring executes the reloaders when files change. %>
# The test environment is used exclusively to run your application's <%- if spring_install? -%>
# test suite. You never need to work with it otherwise. Remember that config.cache_classes = false
# your test database is "scratch space" for the test suite and is wiped <%- else -%>
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true config.cache_classes = true
<%- end -%>
# Do not eager load code on boot. This avoids loading your whole application # Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that # just for the purpose of running a single test. If you are using a tool that

View file

@ -827,6 +827,9 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_spring def test_spring
run_generator run_generator
assert_gem "spring" assert_gem "spring"
assert_file("config/environments/test.rb") do |contents|
assert_match("config.cache_classes = false", contents)
end
end end
def test_bundler_binstub def test_bundler_binstub
@ -857,6 +860,9 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_no_file "config/spring.rb" assert_no_file "config/spring.rb"
assert_no_gem "spring" assert_no_gem "spring"
assert_file("config/environments/test.rb") do |contents|
assert_match("config.cache_classes = true", contents)
end
end end
def test_spring_with_dev_option def test_spring_with_dev_option