diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-04 15:24:26 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-04 15:24:26 -0700 |
commit | 38d92d705e18d953bb0d8f4ba5d156755572acfb (patch) | |
tree | c01f8e1540045c81af038f9887519dd18b7a707c /activerecord/test | |
parent | bd4831d6995102f6003d401b2f257c8f8e553d7b (diff) | |
download | rails-38d92d705e18d953bb0d8f4ba5d156755572acfb.tar.gz rails-38d92d705e18d953bb0d8f4ba5d156755572acfb.tar.bz2 rails-38d92d705e18d953bb0d8f4ba5d156755572acfb.zip |
ensure query cache is cleared when Rack body is closed, fixes bug reported on 951e18abea9c116fc5d6b330ca1dcd2890abe006
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/query_cache_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
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 |