aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2016-05-10 23:00:33 -0400
committerArthur Neves <arthurnn@gmail.com>2016-05-10 23:42:26 -0400
commitd6f3ad7ce7066b8815b4bda4a1e843b2c72c2ad3 (patch)
treeaeec93a2d541a581a700d5c9b5320c641e41589b /activerecord/test
parent932655a4ef61083da98724bb612d00f89e153c46 (diff)
downloadrails-d6f3ad7ce7066b8815b4bda4a1e843b2c72c2ad3.tar.gz
rails-d6f3ad7ce7066b8815b4bda4a1e843b2c72c2ad3.tar.bz2
rails-d6f3ad7ce7066b8815b4bda4a1e843b2c72c2ad3.zip
Make sure we reset the connection_specification_name on
remove_connection When calling `remove_connection` on a model, we delete the pool so we also need to reset the `connection_specification_name` so it will fallback to the parent. This was the current behavior before rails 5, which will fallback to the parent connection pool. [fixes #24959] Special thanks to @jrafanie for working with me on this fix.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/connection_adapters/connection_handler_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
index fc5ca8865b..62beb8bea4 100644
--- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb
+++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -89,6 +89,20 @@ module ActiveRecord
assert_equal @pool.schema_cache.size, Marshal.load(rd.read)
rd.close
end
+
+ def test_a_class_using_custom_pool_and_switching_back_to_primary
+ klass2 = Class.new(Base) { def self.name; 'klass2'; end }
+
+ assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id
+
+ pool = klass2.establish_connection(ActiveRecord::Base.connection_pool.spec.config)
+ assert_equal klass2.connection.object_id, pool.connection.object_id
+ refute_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id
+
+ klass2.remove_connection
+
+ assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id
+ end
end
end
end