aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash_ext_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-01-24 22:12:31 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-01-24 22:12:31 +0000
commit35433859bd9995a9802abc38b1aba379c0019dff (patch)
tree2a0e2f3dfd44e9aa6347fb47060d05b632a7e0cb /activesupport/test/core_ext/hash_ext_test.rb
parent5544231caf768d217bcb85842f6d243f3481bd04 (diff)
downloadrails-35433859bd9995a9802abc38b1aba379c0019dff.tar.gz
rails-35433859bd9995a9802abc38b1aba379c0019dff.tar.bz2
rails-35433859bd9995a9802abc38b1aba379c0019dff.zip
Added Hash#to_query to turn a hash of values into a form-encoded query string [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6038 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext/hash_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 90468fd5a9..cc5d71447b 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -527,3 +527,24 @@ class HashToXmlTest < Test::Unit::TestCase
end
end
end
+
+class QueryTest < Test::Unit::TestCase
+ def test_simple_conversion
+ assert_equal 'a=10', {:a => 10}.to_query
+ end
+
+ def test_nested_conversion
+ assert_equal 'person[name]=Nicholas&person[login]=seckar',
+ {:person => {:name => 'Nicholas', :login => 'seckar'}}.to_query
+ end
+
+ def test_multiple_nested
+ assert_equal 'account[person][id]=20&person[id]=10',
+ {:person => {:id => 10}, :account => {:person => {:id => 20}}}.to_query
+ end
+
+ def test_array_values
+ assert_equal 'person[id][]=10&person[id][]=20',
+ {:person => {:id => [10, 20]}}.to_query
+ end
+end \ No newline at end of file