Permalink
Browse files

Added test for postgres connections as URL. Fixed query param parsing.

  • Loading branch information...
1 parent 89357c8 commit 16249feaab136326ce1a74bb5602517d8d161b6b Glenn Gillen committed with tenderlove Jun 28, 2011
@@ -95,7 +95,7 @@ def self.connection_url_to_hash(url)
: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
@@ -96,6 +96,19 @@ def test_not_specifying_database_name_for_cross_database_selects
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

0 comments on commit 16249fe

Please sign in to comment.