aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/hash_ext_test.rb
diff options
context:
space:
mode:
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