aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2016-08-24 15:07:20 -0500
committerGitHub <noreply@github.com>2016-08-24 15:07:20 -0500
commitef8315ac784aa778b71c803a8aa018676880b396 (patch)
tree3b96515de3d8118081c75ede0f23e02ab0925f9b
parentdd77e1bbfe36cfa002b009e9596ae0c706fabd11 (diff)
parent3df5173d006f190548d38da3445a0dc3af3858ef (diff)
downloadrails-ef8315ac784aa778b71c803a8aa018676880b396.tar.gz
rails-ef8315ac784aa778b71c803a8aa018676880b396.tar.bz2
rails-ef8315ac784aa778b71c803a8aa018676880b396.zip
Merge pull request #26271 from jcoleman/fix-unnecessary-query-cache-busting-test
Test that AR query cache isn't busted when types are not same object
-rw-r--r--activerecord/test/cases/query_cache_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb
index d99e8a1dc6..619a5f4f3f 100644
--- a/activerecord/test/cases/query_cache_test.rb
+++ b/activerecord/test/cases/query_cache_test.rb
@@ -212,6 +212,26 @@ class QueryCacheTest < ActiveRecord::TestCase
end
end
+ def test_query_cached_even_when_types_are_reset
+ Task.cache do
+ # Warm the cache
+ task = Task.find(1)
+
+ Task.connection.type_map.clear
+
+ # Preload the type cache again (so we don't have those queries issued during our assertions)
+ Task.connection.send(:initialize_type_map, Task.connection.type_map)
+
+ # Clear places where type information is cached
+ Task.reset_column_information
+ Task.initialize_find_by_cache
+
+ assert_queries(0) do
+ Task.find(1)
+ end
+ end
+ end
+
private
def middleware(&app)
executor = Class.new(ActiveSupport::Executor)