mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
59d252196b
commit
537a342a83
2 changed files with 9 additions and 1 deletions
|
@ -132,7 +132,8 @@ module ActiveRecord
|
|||
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 @@ module ActiveRecord
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue