diff options
author | Arthur Neves <arthurnn@gmail.com> | 2016-05-04 14:05:31 -0500 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2016-05-05 15:29:11 -0500 |
commit | 79154a3281eb25a573dfcb5d5db31c3c481311f9 (patch) | |
tree | c824f527cbead1f3e6bdaa452ace58b0fa3cceec /activerecord/test | |
parent | c1bc0d83def740648fdbed05fcc3283dcef1f07d (diff) | |
download | rails-79154a3281eb25a573dfcb5d5db31c3c481311f9.tar.gz rails-79154a3281eb25a573dfcb5d5db31c3c481311f9.tar.bz2 rails-79154a3281eb25a573dfcb5d5db31c3c481311f9.zip |
Use spec key, when given as spec_id
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/connection_adapters/connection_handler_test.rb | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb index c3cdb29380..47e8486ded 100644 --- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb +++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb @@ -6,10 +6,19 @@ module ActiveRecord def setup @handler = ConnectionHandler.new resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new Base.configurations - spec = resolver.spec(:arunit) - @spec_id = "primary" - @pool = @handler.establish_connection(spec) + @pool = @handler.establish_connection(resolver.spec(:arunit, @spec_id)) + end + + def test_establish_connection_uses_spec_id + config = {"readonly" => {"adapter" => 'sqlite3'}} + resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(config) + spec = resolver.spec(:readonly) + @handler.establish_connection(spec) + + assert_not_nil @handler.retrieve_connection_pool('readonly') + ensure + @handler.remove_connection('readonly') end def test_retrieve_connection @@ -24,31 +33,18 @@ module ActiveRecord assert !@handler.active_connections? end -# def test_retrieve_connection_pool_with_ar_base -# assert_nil @handler.retrieve_connection_pool(ActiveRecord::Base) -# end - def test_retrieve_connection_pool assert_not_nil @handler.retrieve_connection_pool(@spec_id) 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 -# sub_pool = @handler.establish_connection(@subklass, Base.connection_pool.spec) -# assert_same sub_pool, @handler.retrieve_connection_pool(@subklass) -# -# @handler.remove_connection @subklass -# assert_same @pool, @handler.retrieve_connection_pool(@subklass) -# end + def test_retrieve_connection_pool_with_invalid_id + assert_nil @handler.retrieve_connection_pool("foo") + end def test_connection_pools assert_equal([@pool], @handler.connection_pools) end - # TODO if Process.respond_to?(:fork) def test_connection_pool_per_pid object_id = ActiveRecord::Base.connection.object_id |