mirror of
https://github.com/github/rails.git
synced 2026-01-25 14:28:28 -05:00
Ensure ActiveRecord::ConnectionPool.connected? handles undefined connections. [#936 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
committed by
Pratik Naik
parent
5fad229e43
commit
32089cbcc9
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user