From 38d92d705e18d953bb0d8f4ba5d156755572acfb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 4 May 2011 15:24:26 -0700 Subject: ensure query cache is cleared when Rack body is closed, fixes bug reported on 951e18abea9c116fc5d6b330ca1dcd2890abe006 --- activerecord/test/cases/query_cache_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index b2e40c6b22..a61180cfaf 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -65,6 +65,17 @@ class QueryCacheTest < ActiveRecord::TestCase assert !ActiveRecord::Base.connection.query_cache_enabled, 'cache disabled' end + def test_cache_clear_after_close + mw = ActiveRecord::QueryCache.new lambda { |env| + Post.find(:first) + } + body = mw.call({}).last + + assert !ActiveRecord::Base.connection.query_cache.empty?, 'cache not empty' + body.close + assert ActiveRecord::Base.connection.query_cache.empty?, 'cache should be empty' + end + def test_find_queries assert_queries(ActiveRecord::IdentityMap.enabled? ? 1 : 2) { Task.find(1); Task.find(1) } end -- cgit v1.2.3