diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-11-06 01:29:09 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-11-06 01:29:09 +0530 |
commit | 0832bc63f4047d0ad0171c411460db23450213aa (patch) | |
tree | 550b8a8cf1bebfc000d83b40f519cbc9eb169140 | |
parent | 396d599e24cbfa15c62b20fab8cc02cdba046ce3 (diff) | |
download | rails-0832bc63f4047d0ad0171c411460db23450213aa.tar.gz rails-0832bc63f4047d0ad0171c411460db23450213aa.tar.bz2 rails-0832bc63f4047d0ad0171c411460db23450213aa.zip |
Make sure ActiveRecord::Base.connected? doesn't raise an exception for defined connections
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 3 | ||||
-rw-r--r-- | activerecord/test/cases/pooled_connections_test.rb | 5 |
2 files changed, 7 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 3016c329bd..54a17e20a9 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,8 @@ module ActiveRecord # Returns true if a connection that's accessible to this class has # already been opened. def connected?(klass) - conn = retrieve_connection_pool(klass) ? conn.connected? : false + conn = retrieve_connection_pool(klass) + conn ? 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 3e8c617a89..36b45868b9 100644 --- a/activerecord/test/cases/pooled_connections_test.rb +++ b/activerecord/test/cases/pooled_connections_test.rb @@ -74,6 +74,11 @@ class PooledConnectionsTest < ActiveRecord::TestCase conn_pool.checkin(conn) end + def test_not_connected_defined_connection_reutnrs_false + ActiveRecord::Base.establish_connection(@connection) + assert ! ActiveRecord::Base.connected? + end + def test_undefined_connection_returns_false old_handler = ActiveRecord::Base.connection_handler ActiveRecord::Base.connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new |