diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-01-16 13:03:07 +0530 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2016-01-22 11:19:10 +0530 |
commit | 66023eccb66f327d174685686f98955030d820f2 (patch) | |
tree | 865cc3d17a47dc3c05b791b4ed27970996fe2793 /activerecord/test | |
parent | a688c0317deee754b517f73668ced4ca1523c5a5 (diff) | |
download | rails-66023eccb66f327d174685686f98955030d820f2.tar.gz rails-66023eccb66f327d174685686f98955030d820f2.tar.bz2 rails-66023eccb66f327d174685686f98955030d820f2.zip |
Fix ActiveRecord::Relation#cache_key for relations with no results
- When relations return no result or 0 result then cache_key should
handle it gracefully instead of blowing up trying to access
`result[:size]` and `result[:timestamp]`.
- Fixes #23063.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/collection_cache_key_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/collection_cache_key_test.rb b/activerecord/test/cases/collection_cache_key_test.rb index 93e7b9cff6..6b34979e4a 100644 --- a/activerecord/test/cases/collection_cache_key_test.rb +++ b/activerecord/test/cases/collection_cache_key_test.rb @@ -74,5 +74,10 @@ module ActiveRecord assert_match(/\Acomments\/query-(\h+)-0\Z/, empty_loaded_collection.cache_key) end + + test "cache_key for queries with offset which return 0 rows" do + developers = Developer.offset(20) + assert_match(/\Adevelopers\/query-(\h+)-0\Z/, developers.cache_key) + end end end |