Permalink
Browse files

ensure that released connections move between threads

  • Loading branch information...
1 parent cff19cf commit 94b2c8c32d00e101b306875b86abf11b28b55699 @tenderlove tenderlove committed Mar 9, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 activerecord/test/cases/connection_pool_test.rb
@@ -31,6 +31,24 @@ def active_connections(pool)
pool.connections.find_all(&:in_use?)
end
+ def test_released_connection_moves_between_threads
+ thread_conn = nil
+
+ Thread.new {
+ pool.with_connection do |conn|
+ thread_conn = conn
+ end
+ }.join
+
+ assert thread_conn
+
+ Thread.new {
+ pool.with_connection do |conn|
+ assert_equal thread_conn, conn
+ end
+ }.join
+ end
+
def test_with_connection
assert_equal 0, active_connections(pool).size

0 comments on commit 94b2c8c

Please sign in to comment.