Cache compiled view templates when running tests by default #38269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When generating a new app without
--skip-spring
, caching classes is disabled inenvironments/test.rb
. This implicitly disables caching view templates too. This change enables template caching by adding this to the generatedenvironments/test.rb
:Other Information
I think disabling compiled templates caching was an unintended side effect of this commit.
We detected this problem because we were getting intermittent errors of this kind when running our suite of system tests:
Investigating a little bit, we saw that the reason was that
ActionView::CacheExpiry
was clearing the cache when the list of view paths was modified during test execution. This was happening when referencing a mailer class that was using#append_view_path
(loading that class was modifying the list of paths). I haven't been able to reproduce this problem with a simple app yet (to open a bug), but this tweak fixed the issue for us and I believe it's a better default for Rails.cc @kaspth