diff options
author | schneems <richard.schneeman+foo@gmail.com> | 2018-09-20 13:56:07 -0500 |
---|---|---|
committer | schneems <richard.schneeman+foo@gmail.com> | 2018-09-20 15:31:38 -0500 |
commit | 135d3e15b72b9820212027b057df8980140a947b (patch) | |
tree | 3d2b41d17c4603aced3a9d414af27327b95e2229 /railties | |
parent | b45b96b91fc62e7488002cb05c96ec78577f7873 (diff) | |
download | rails-135d3e15b72b9820212027b057df8980140a947b.tar.gz rails-135d3e15b72b9820212027b057df8980140a947b.tar.bz2 rails-135d3e15b72b9820212027b057df8980140a947b.zip |
[close #33907] Error when using "recyclable" cache keys with a store that does not support it
If you are using the "in cache versioning" also known as "recyclable cache keys" the cache store must be aware of this scheme, otherwise you will generate cache entries that never invalidate.
This PR adds a check to the initialization process to ensure that if recyclable cache keys are being used via
```
config.active_record.cache_versioning = true
```
Then the cache store needs to show that it supports this versioning scheme. Cache stores can let Rails know that they support this scheme by adding a method `supports_in_cache_versioning?` and returning true.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 5 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 691e599ddb..da4beedecf 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,8 @@ +* Raise an error when "recyclable cache keys" are being used by a cache store + that does not explicitly support it. + + *Richard Schneeman* + * Support environment specific credentials file. For `production` environment look first for `config/credentials/production.yml.enc` file that can be decrypted by diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 11cd6dd1e6..386b4f76e6 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -124,6 +124,18 @@ module ApplicationTests assert_equal "MyLogger", Rails.application.config.logger.class.name end + test "raises an error if cache does not support recyclable cache keys" do + build_app(initializers: true) + add_to_env_config "production", "config.cache_store = Class.new {}.new" + add_to_env_config "production", "config.active_record.cache_versioning = true" + + error = assert_raise(RuntimeError) do + app "production" + end + + assert_match(/You're using a cache store/, error.message) + end + test "a renders exception on pending migration" do add_to_config <<-RUBY config.active_record.migration_error = :page_load |