diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-02 11:13:49 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-05-02 11:13:49 -0700 |
commit | 3066ea8b44503c16b1a0ad5860ae01470912151a (patch) | |
tree | 44f27f1951577bce661783dd5b36526b65d309b8 /activerecord | |
parent | 3fc37e8ef96b3f139427189b58c426ec7fff65be (diff) | |
download | rails-3066ea8b44503c16b1a0ad5860ae01470912151a.tar.gz rails-3066ea8b44503c16b1a0ad5860ae01470912151a.tar.bz2 rails-3066ea8b44503c16b1a0ad5860ae01470912151a.zip |
add a couple test cases surrounding query cache middleware
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/query_cache_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index 287f7e255b..ebe7cae04a 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -12,6 +12,24 @@ class QueryCacheTest < ActiveRecord::TestCase Task.connection.clear_query_cache end + def test_middleware_delegates + called = false + mw = ActiveRecord::QueryCache.new lambda { |env| + called = true + } + mw.call({}) + assert called, 'middleware should delegate' + end + + def test_middleware + mw = ActiveRecord::QueryCache.new lambda { |env| + Task.find 1 + Task.find 1 + assert_equal 1, ActiveRecord::Base.connection.query_cache.length + } + mw.call({}) + end + def test_find_queries assert_queries(ActiveRecord::IdentityMap.enabled? ? 1 : 2) { Task.find(1); Task.find(1) } end |