aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-04-22 12:56:43 -0600
committerSean Griffin <sean@seantheprogrammer.com>2016-04-22 12:56:43 -0600
commit1ca6f7f7676c5933cc5c6bff5aeabf362aa1ba59 (patch)
tree9d5257b01dfe6f31f72d57de035f22f4f672f839 /activerecord/test
parent4a06cc9edd8ecc71392de457bc70b4bc79b162ed (diff)
downloadrails-1ca6f7f7676c5933cc5c6bff5aeabf362aa1ba59.tar.gz
rails-1ca6f7f7676c5933cc5c6bff5aeabf362aa1ba59.tar.bz2
rails-1ca6f7f7676c5933cc5c6bff5aeabf362aa1ba59.zip
Do not attempt to return connection with open transaction to pool (#24610)
When the query cache completes, if Active Record is still inside of a transaction, it is because the transaction is meant to be left open above this unit of work (such as transactional fixtures in tests). There were several tests around the behavior of "tests" that were invalid, as tests are not run through the executor. They have been changed to reflect the new behavior, which is closer to what actually occurs in Rails tests. Fixes #23989 Fixes #24491 Close #24500
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/connection_management_test.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/activerecord/test/cases/connection_management_test.rb b/activerecord/test/cases/connection_management_test.rb
index c4c2c69d1c..1f9b6add7a 100644
--- a/activerecord/test/cases/connection_management_test.rb
+++ b/activerecord/test/cases/connection_management_test.rb
@@ -4,6 +4,8 @@ require "rack"
module ActiveRecord
module ConnectionAdapters
class ConnectionManagementTest < ActiveRecord::TestCase
+ self.use_transactional_tests = false
+
class App
attr_reader :calls
def initialize
@@ -46,8 +48,8 @@ module ActiveRecord
assert !ActiveRecord::Base.connection_handler.active_connections?
end
- def test_active_connections_are_not_cleared_on_body_close_during_test
- executor.wrap do
+ def test_active_connections_are_not_cleared_on_body_close_during_transaction
+ ActiveRecord::Base.transaction do
_, _, body = @management.call(@env)
body.close
assert ActiveRecord::Base.connection_handler.active_connections?
@@ -61,9 +63,9 @@ module ActiveRecord
assert !ActiveRecord::Base.connection_handler.active_connections?
end
- def test_connections_not_closed_if_exception_and_test
- executor.wrap do
- app = Class.new(App) { def call(env); raise; end }.new
+ def test_connections_not_closed_if_exception_inside_transaction
+ ActiveRecord::Base.transaction do
+ app = Class.new(App) { def call(env); raise RuntimeError; end }.new
explosive = middleware(app)
assert_raises(RuntimeError) { explosive.call(@env) }
assert ActiveRecord::Base.connection_handler.active_connections?