diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-06 17:43:14 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-09-06 17:43:58 -0700 |
commit | 4edf6ea0eae9cb8be46a2e963e047eb89a0f5531 (patch) | |
tree | a45314930cb5532aa1579e0290d153be683facc6 /activerecord/test/cases/connection_adapters/connection_handler_test.rb | |
parent | f6ced69a11cdff56c2e87b84e775ef09c6d999d1 (diff) | |
download | rails-4edf6ea0eae9cb8be46a2e963e047eb89a0f5531.tar.gz rails-4edf6ea0eae9cb8be46a2e963e047eb89a0f5531.tar.bz2 rails-4edf6ea0eae9cb8be46a2e963e047eb89a0f5531.zip |
Merge pull request #2897 from rsutphin/ar31-remove_connection
Patch for issue #2820
Diffstat (limited to 'activerecord/test/cases/connection_adapters/connection_handler_test.rb')
-rw-r--r-- | activerecord/test/cases/connection_adapters/connection_handler_test.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index abf317768f..bd0d161838 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -6,7 +6,12 @@ module ActiveRecord def setup @handler = ConnectionHandler.new @handler.establish_connection 'america', Base.connection_pool.spec - @klass = Struct.new(:name).new('america') + @klass = Class.new do + def self.name; 'america'; end + end + @subklass = Class.new(@klass) do + def self.name; 'north america'; end + end end def test_retrieve_connection @@ -28,6 +33,20 @@ module ActiveRecord def test_retrieve_connection_pool assert_not_nil @handler.retrieve_connection_pool(@klass) end + + def test_retrieve_connection_pool_uses_superclass_when_no_subclass_connection + assert_not_nil @handler.retrieve_connection_pool(@subklass) + end + + def test_retrieve_connection_pool_uses_superclass_pool_after_subclass_establish_and_remove + @handler.establish_connection 'north america', Base.connection_pool.spec + assert_not_same @handler.retrieve_connection_pool(@klass), + @handler.retrieve_connection_pool(@subklass) + + @handler.remove_connection @subklass + assert_same @handler.retrieve_connection_pool(@klass), + @handler.retrieve_connection_pool(@subklass) + end end end end |