diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-02-24 11:34:32 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-24 11:34:32 -0600 |
commit | 1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3 (patch) | |
tree | 240347e78d8877a4e98ea9fdda82f5c57428b620 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | d32eb410f19f6872df1e1e1810840c0f5aa13b50 (diff) | |
download | rails-1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3.tar.gz rails-1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3.tar.bz2 rails-1b22071b276a2a2b3e65e6db40c6a0aa92d9ebc3.zip |
Ensure ActiveRecord session store's connections are checked in after each request [#1927 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 901b17124c..aac84cc5f4 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -351,5 +351,21 @@ module ActiveRecord retrieve_connection_pool klass.superclass end end + + class ConnectionManagement + def initialize(app) + @app = app + end + + def call(env) + @app.call(env) + ensure + # Don't return connection (and peform implicit rollback) if + # this request is a part of integration test + unless env.key?("rack.test") + ActiveRecord::Base.clear_active_connections! + end + end + end end end |