From a3f12f575d4bf216a15188ecab2d26a11162bc3b Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Thu, 4 Sep 2008 15:16:29 +0200 Subject: Default connection allow_concurrency to false (for PostgreSQL) Signed-off-by: Jeremy Kemper --- activerecord/lib/active_record/test_case.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activerecord/lib/active_record/test_case.rb') diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb index ffaa41282f..eabf06fc3b 100644 --- a/activerecord/lib/active_record/test_case.rb +++ b/activerecord/lib/active_record/test_case.rb @@ -43,5 +43,20 @@ module ActiveRecord def assert_no_queries(&block) assert_queries(0, &block) end + + def self.use_concurrent_connections + setup :connection_allow_concurrency_setup + teardown :connection_allow_concurrency_teardown + end + + def connection_allow_concurrency_setup + @connection = ActiveRecord::Base.remove_connection + ActiveRecord::Base.establish_connection(@connection.merge({:allow_concurrency => true})) + end + + def connection_allow_concurrency_teardown + ActiveRecord::Base.clear_all_connections! + ActiveRecord::Base.establish_connection(@connection) + end end end -- cgit v1.2.3