diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-11-28 13:07:42 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-11-28 15:23:25 -0800 |
commit | dde21138673c111099890301ffce8b6185e9ea3c (patch) | |
tree | 996109050a3f3babca0ee5021e8d6a706cbd1068 /activerecord/test/cases/connection_specification/resolver_test.rb | |
parent | 30f7c59e9010ccdfa601f28e22fd4e449f266df1 (diff) | |
download | rails-dde21138673c111099890301ffce8b6185e9ea3c.tar.gz rails-dde21138673c111099890301ffce8b6185e9ea3c.tar.bz2 rails-dde21138673c111099890301ffce8b6185e9ea3c.zip |
Move connection resoluion logic to it's own testable class.
Diffstat (limited to 'activerecord/test/cases/connection_specification/resolver_test.rb')
-rw-r--r-- | activerecord/test/cases/connection_specification/resolver_test.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_specification/resolver_test.rb b/activerecord/test/cases/connection_specification/resolver_test.rb new file mode 100644 index 0000000000..1ca9a00c85 --- /dev/null +++ b/activerecord/test/cases/connection_specification/resolver_test.rb @@ -0,0 +1,41 @@ +require "cases/helper" + +module ActiveRecord + class Base + class ConnectionSpecification + class ResolverTest < ActiveRecord::TestCase + def resolve(spec) + Resolver.new(spec, ActiveRecord::Base, {}).spec.config + end + + def test_url_host_no_db + spec = resolve 'postgres://foo?encoding=utf8' + assert_equal({ + :adapter => "postgresql", + :database => "", + :host => "foo", + :encoding => "utf8" }, spec) + end + + def test_url_host_db + spec = resolve 'postgres://foo/bar?encoding=utf8' + assert_equal({ + :adapter => "postgresql", + :database => "bar", + :host => "foo", + :encoding => "utf8" }, spec) + end + + def test_url_port + spec = resolve 'postgres://foo:123?encoding=utf8' + assert_equal({ + :adapter => "postgresql", + :database => "", + :port => 123, + :host => "foo", + :encoding => "utf8" }, spec) + end + end + end + end +end |