diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-11-29 11:48:55 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-11-29 11:48:55 -0800 |
commit | f73f53455a01a93bd90cb8c0cee1a7c54afdb301 (patch) | |
tree | e146be7d30d3e70fc946a64d1c81fceb9cfc073e /activerecord | |
parent | 2169603385a447256d713873be6b2fbb6e2591fa (diff) | |
download | rails-f73f53455a01a93bd90cb8c0cee1a7c54afdb301.tar.gz rails-f73f53455a01a93bd90cb8c0cee1a7c54afdb301.tar.bz2 rails-f73f53455a01a93bd90cb8c0cee1a7c54afdb301.zip |
respond_to? information of AR is not the responsibility of the spec
resolver.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 16 | ||||
-rw-r--r-- | activerecord/test/cases/connection_specification/resolver_test.rb | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index f2e7f88011..ca9fb11e95 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -11,9 +11,8 @@ module ActiveRecord class Resolver # :nodoc: attr_reader :config, :klass, :configurations - def initialize(config, klass, configurations) + def initialize(config, configurations) @config = config - @klass = klass @configurations = configurations end @@ -52,9 +51,6 @@ module ActiveRecord end adapter_method = "#{spec[:adapter]}_connection" - unless klass.respond_to?(adapter_method) - raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" - end ConnectionSpecification.new(spec, adapter_method) end @@ -127,9 +123,15 @@ module ActiveRecord # The exceptions AdapterNotSpecified, AdapterNotFound and ArgumentError # may be returned on an error. def self.establish_connection(spec = ENV["DATABASE_URL"]) - resolver = ConnectionSpecification::Resolver.new spec, self, configurations + resolver = ConnectionSpecification::Resolver.new spec, configurations + spec = resolver.spec + + unless respond_to?(spec.adapter_method) + raise AdapterNotFound, "database configuration specifies nonexistent #{spec[:adapter]} adapter" + end + remove_connection - connection_handler.establish_connection name, resolver.spec + connection_handler.establish_connection name, spec end class << self diff --git a/activerecord/test/cases/connection_specification/resolver_test.rb b/activerecord/test/cases/connection_specification/resolver_test.rb index a7623d0a66..d4b0f236ee 100644 --- a/activerecord/test/cases/connection_specification/resolver_test.rb +++ b/activerecord/test/cases/connection_specification/resolver_test.rb @@ -5,7 +5,7 @@ module ActiveRecord class ConnectionSpecification class ResolverTest < ActiveRecord::TestCase def resolve(spec) - Resolver.new(spec, ActiveRecord::Base, {}).spec.config + Resolver.new(spec, {}).spec.config end def test_url_host_no_db |