Skip to content

Commit db0ee28

Browse files
committed
Enable eager loading by default on CI systems
This is a pattern we've been using for ages at Shopify. When you are running test locally, most of the time you run only a subset, so it's better to load as little code as possible to have a faster time to first test result. But when you are on CI, it's usally much preferable to eager load the whole application because you will likely need all the code anyway, and even if the test suite is split across runners, it's preferable to load all the code to ensure any codefile that may have side effects is loaded. This also ensure that if some autoloaded constants are not properly tested on CI, at least they'll be loaded and obvious errors (e.g. SyntaxError) will be caught on CI rather than during deploy.
1 parent 2451a56 commit db0ee28

File tree

1 file changed

+1
-1
lines changed
  • railties/lib/rails/generators/rails/app/templates/config/environments

1 file changed

+1
-1
lines changed

railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Rails.application.configure do
1414
# Do not eager load code on boot. This avoids loading your whole application
1515
# just for the purpose of running a single test. If you are using a tool that
1616
# preloads Rails for running tests, you may have to set it to true.
17-
config.eager_load = false
17+
config.eager_load = ENV["CI"].present?
1818

1919
# Configure public file server for tests with Cache-Control for performance.
2020
config.public_file_server.enabled = true

0 commit comments

Comments
 (0)