adding active_connection? to the connection pool
This commit is contained in:
parent
ec0cacc293
commit
4211866b7a
@ -151,6 +151,12 @@ def connection
|
||||
@reserved_connections[current_connection_id] ||= checkout
|
||||
end
|
||||
|
||||
# Check to see if there is an active connection in this connection
|
||||
# pool.
|
||||
def active_connection?
|
||||
@reserved_connections.key? current_connection_id
|
||||
end
|
||||
|
||||
# Signal that the thread is finished with the current connection.
|
||||
# #release_connection releases the connection-thread association
|
||||
# and returns the connection to the pool.
|
||||
|
@ -18,6 +18,14 @@ def setup
|
||||
end
|
||||
end
|
||||
|
||||
def test_active_connection?
|
||||
assert !@pool.active_connection?
|
||||
assert @pool.connection
|
||||
assert @pool.active_connection?
|
||||
@pool.release_connection
|
||||
assert !@pool.active_connection?
|
||||
end
|
||||
|
||||
def test_pool_caches_columns
|
||||
columns = @pool.columns['posts']
|
||||
assert_equal columns, @pool.columns['posts']
|
||||
|
Loading…
Reference in New Issue
Block a user