From 405aeb5da4eea3b9defdea2ce0920725dcd75308 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 30 Dec 2011 15:39:39 -0800 Subject: connection pool starts the reaper --- activerecord/test/cases/reaper_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/reaper_test.rb b/activerecord/test/cases/reaper_test.rb index 2fa544962a..9149d45e7c 100644 --- a/activerecord/test/cases/reaper_test.rb +++ b/activerecord/test/cases/reaper_test.rb @@ -52,6 +52,22 @@ module ActiveRecord pool = ConnectionPool.new spec assert_equal 100, pool.reaper.frequency end + + def test_connection_pool_starts_reaper + spec = ActiveRecord::Base.connection_pool.spec.dup + spec.config[:reaping_frequency] = 0.0001 + + pool = ConnectionPool.new spec + pool.timeout = 0 + + conn = pool.checkout + count = pool.connections.length + + conn.extend(Module.new { def active?; false; end; }) + + sleep 0.0002 + assert_equal(count - 1, pool.connections.length) + end end end end -- cgit v1.2.3