Permalink
Browse files

Make sure ActiveRecord::Base.connected? doesn't raise an exception fo…

…r defined connections
  • Loading branch information...
1 parent 396d599 commit 0832bc63f4047d0ad0171c411460db23450213aa @lifo lifo committed Nov 5, 2008
@@ -324,7 +324,8 @@ def retrieve_connection(klass) #:nodoc:
# 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
@@ -74,6 +74,11 @@ def test_pooled_connection_checkout_existing_first
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

0 comments on commit 0832bc6

Please sign in to comment.