remove_connection should not remove parent connection

When calling remove_connection in a subclass, that should not fallback
to the parent, otherwise it will remove the parent connection from the
handler.
上级 59d25219
......@@ -132,7 +132,8 @@ def connected?
connection_handler.connected?(connection_specification_name)
end
def remove_connection(name = connection_specification_name)
def remove_connection(name = nil)
name ||= @connection_specification_name if defined?(@connection_specification_name)
# if removing a connection that have a pool, we reset the
# connection_specification_name so it will use the parent
# pool.
......
......@@ -112,6 +112,13 @@ def test_connection_specification_name_should_fallback_to_parent
klassA.connection_specification_name = "readonly"
assert_equal "readonly", klassB.connection_specification_name
end
def test_remove_connection_should_not_remove_parent
klass2 = Class.new(Base) { def self.name; 'klass2'; end }
klass2.remove_connection
refute_nil ActiveRecord::Base.connection.object_id
assert_equal klass2.connection.object_id, ActiveRecord::Base.connection.object_id
end
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册