Skip to content
This repository
Browse code

ensure that released connections move between threads

  • Loading branch information...
commit 657095d8bbec51999d66b379245e8d3466ee27af 1 parent d523504
Aaron Patterson authored March 08, 2012
18  activerecord/test/cases/connection_pool_test.rb
@@ -31,6 +31,24 @@ def active_connections(pool)
31 31
         pool.connections.find_all(&:in_use?)
32 32
       end
33 33
 
  34
+      def test_released_connection_moves_between_threads
  35
+        thread_conn = nil
  36
+
  37
+        Thread.new {
  38
+          pool.with_connection do |conn|
  39
+            thread_conn = conn
  40
+          end
  41
+        }.join
  42
+
  43
+        assert thread_conn
  44
+
  45
+        Thread.new {
  46
+          pool.with_connection do |conn|
  47
+            assert_equal thread_conn, conn
  48
+          end
  49
+        }.join
  50
+      end
  51
+
34 52
       def test_with_connection
35 53
         assert_equal 0, active_connections(pool).size
36 54
 

0 notes on commit 657095d

Please sign in to comment.
Something went wrong with that request. Please try again.