aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-03-08 16:12:49 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-03-08 16:13:12 -0800
commit94b2c8c32d00e101b306875b86abf11b28b55699 (patch)
treebd66eabd0db2bf54341ba20e6798f3da850f381c /activerecord/test
parentcff19cf545de61ada8904d9d3daaaa594a9a931f (diff)
downloadrails-94b2c8c32d00e101b306875b86abf11b28b55699.tar.gz
rails-94b2c8c32d00e101b306875b86abf11b28b55699.tar.bz2
rails-94b2c8c32d00e101b306875b86abf11b28b55699.zip
ensure that released connections move between threads
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/connection_pool_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb
index ea3b159015..dd0acfdd03 100644
--- a/activerecord/test/cases/connection_pool_test.rb
+++ b/activerecord/test/cases/connection_pool_test.rb
@@ -31,6 +31,24 @@ module ActiveRecord
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