diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-11-06 01:07:10 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-11-06 01:07:10 +0530 |
commit | 215122890b8cecca3809d981accd84bfd5486196 (patch) | |
tree | 11dd8368e2674342098af21136893bee491c44ff /activerecord | |
parent | 94f3a94b0b66e576287f48627282dc1a21bf51a7 (diff) | |
parent | 32089cbcc9ca3fb935f783e7a7ef2b60b7d43006 (diff) | |
download | rails-215122890b8cecca3809d981accd84bfd5486196.tar.gz rails-215122890b8cecca3809d981accd84bfd5486196.tar.bz2 rails-215122890b8cecca3809d981accd84bfd5486196.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/pooled_connections_test.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 432c341e6c..3016c329bd 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -324,7 +324,7 @@ module ActiveRecord # Returns true if a connection that's accessible to this class has # already been opened. def connected?(klass) - retrieve_connection_pool(klass).connected? + conn = retrieve_connection_pool(klass) ? conn.connected? : false end # Remove the connection for this class. This will close the active diff --git a/activerecord/test/cases/pooled_connections_test.rb b/activerecord/test/cases/pooled_connections_test.rb index 078ca1d679..3e8c617a89 100644 --- a/activerecord/test/cases/pooled_connections_test.rb +++ b/activerecord/test/cases/pooled_connections_test.rb @@ -73,6 +73,14 @@ class PooledConnectionsTest < ActiveRecord::TestCase assert ActiveRecord::ConnectionAdapters::AbstractAdapter === conn conn_pool.checkin(conn) end + + def test_undefined_connection_returns_false + old_handler = ActiveRecord::Base.connection_handler + ActiveRecord::Base.connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new + assert_equal false, ActiveRecord::Base.connected? + ensure + ActiveRecord::Base.connection_handler = old_handler + end end unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name class AllowConcurrencyDeprecatedTest < ActiveRecord::TestCase |