diff options
author | Glenn Gillen <me@glenngillen.com> | 2011-06-28 19:47:54 +0100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-07-20 16:23:31 -0700 |
commit | 16249feaab136326ce1a74bb5602517d8d161b6b (patch) | |
tree | 49b8cd163ed68dacd3060ddf17986bdf8135800f | |
parent | 89357c8f834f638210d004ae9426aaa052dd519b (diff) | |
download | rails-16249feaab136326ce1a74bb5602517d8d161b6b.tar.gz rails-16249feaab136326ce1a74bb5602517d8d161b6b.tar.bz2 rails-16249feaab136326ce1a74bb5602517d8d161b6b.zip |
Added test for postgres connections as URL. Fixed query param parsing.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 13 |
2 files changed, 14 insertions, 1 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 d008aabcae..c34bb55054 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -95,7 +95,7 @@ module ActiveRecord :host => config.host } spec.reject!{ |key,value| value.nil? } if config.query - options = Hash[query.split("&").map{ |pair| pair.split("=") }].symbolize_keys + options = Hash[config.query.split("&").map{ |pair| pair.split("=") }].symbolize_keys spec.merge!(options) end spec diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index da57349d93..52496bf221 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -96,6 +96,19 @@ class AdapterTest < ActiveRecord::TestCase def test_encoding assert_not_nil @connection.encoding end + + def test_connect_with_url + begin + ar_config = ARTest.connection_config['arunit'] + url = "postgres://#{ar_config["username"]}@localhost/#{ar_config["database"]}?encoding=utf8" + ActiveRecord::Base.establish_connection(url) + connection = ActiveRecord::Base.connection + assert_equal ar_config['database'], connection.current_database + assert_equal "UTF8", connection.encoding + ensure + ActiveRecord::Base.establish_connection 'arunit' + end + end end def test_table_alias |