diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-25 06:36:43 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-25 06:36:43 -0700 |
commit | 8800aae3128056b4c9fc4cbc1e116a6817052898 (patch) | |
tree | 2d274b9e8a2e4d258ddba85a3b47d7397898306c /activerecord/test/cases/connection_pool_test.rb | |
parent | 114e1802132c944263a44af5f81da6d43c78124b (diff) | |
parent | 39087068c2e3c85f6839ea51eab4480673138a2b (diff) | |
download | rails-8800aae3128056b4c9fc4cbc1e116a6817052898.tar.gz rails-8800aae3128056b4c9fc4cbc1e116a6817052898.tar.bz2 rails-8800aae3128056b4c9fc4cbc1e116a6817052898.zip |
Merge pull request #7684 from jrochkind/connection_pool_timeout_key_backport
ConnectionPool accepts spec key 'checkout_timeout' (Backport)
Diffstat (limited to 'activerecord/test/cases/connection_pool_test.rb')
-rw-r--r-- | activerecord/test/cases/connection_pool_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb index 5cecfa90e7..98759544b6 100644 --- a/activerecord/test/cases/connection_pool_test.rb +++ b/activerecord/test/cases/connection_pool_test.rb @@ -151,6 +151,28 @@ module ActiveRecord def test_pool_sets_connection_visitor assert @pool.connection.visitor.is_a?(Arel::Visitors::ToSql) end + + def test_timeout_spec_keys + # 'wait_timeout' is supported for backwards compat, + # 'checkout_timeout' is preferred to avoid conflicting + # with mysql2 adapters key of name 'wait_timeout' but + # different meaning. + config = ActiveRecord::Base.connection_pool.spec.config.merge(:wait_timeout => nil, :connection_timeout => nil) + method = ActiveRecord::Base.connection_pool.spec.adapter_method + + pool = ConnectionPool.new ActiveRecord::Base::ConnectionSpecification.new(config.merge(:wait_timeout => 1), method) + assert_equal 1, pool.instance_variable_get(:@timeout) + pool.disconnect! + + pool = ConnectionPool.new ActiveRecord::Base::ConnectionSpecification.new(config.merge(:checkout_timeout => 1), method) + assert_equal 1, pool.instance_variable_get(:@timeout) + pool.disconnect! + + pool = ConnectionPool.new ActiveRecord::Base::ConnectionSpecification.new(config.merge(:wait_timeout => 6000, :checkout_timeout => 1), method) + assert_equal 1, pool.instance_variable_get(:@timeout) + pool.disconnect! + end + end end end |