aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-01-22 16:07:59 +1030
committerMatthew Draper <matthew@trebex.net>2016-01-22 16:07:59 +1030
commita688c0317deee754b517f73668ced4ca1523c5a5 (patch)
treed471aa9cac34fd53f175062f9facf375df6d1790 /activerecord/test
parent6fcc3c47eb363d0d3753ee284de2fbc68df03194 (diff)
parent8126925447b6ba2e26c4bca4b4e10fb99803483b (diff)
downloadrails-a688c0317deee754b517f73668ced4ca1523c5a5.tar.gz
rails-a688c0317deee754b517f73668ced4ca1523c5a5.tar.bz2
rails-a688c0317deee754b517f73668ced4ca1523c5a5.zip
Merge pull request #23080 from prathamesh-sonpatki/fix-cache-key-for-loaded-empty-collection
Fix ActiveRecord::Relation#cache_key for loaded empty collection
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/collection_cache_key_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/collection_cache_key_test.rb b/activerecord/test/cases/collection_cache_key_test.rb
index 53058c5a4a..93e7b9cff6 100644
--- a/activerecord/test/cases/collection_cache_key_test.rb
+++ b/activerecord/test/cases/collection_cache_key_test.rb
@@ -66,5 +66,13 @@ module ActiveRecord
developers = projects(:active_record).developers
assert_match(/\Adevelopers\/query-(\h+)-(\d+)-(\d+)\Z/, developers.cache_key)
end
+
+ test "cache_key for loaded collection with zero size" do
+ Comment.delete_all
+ posts = Post.includes(:comments)
+ empty_loaded_collection = posts.first.comments
+
+ assert_match(/\Acomments\/query-(\h+)-0\Z/, empty_loaded_collection.cache_key)
+ end
end
end