aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/object/to_query_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-28 20:51:21 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-28 20:51:21 -0300
commit6924f848c45897004ba9cc4f96c032286dcce346 (patch)
tree9142119eaada73dbcb34d287b5d24f1cda92d6e0 /activesupport/test/core_ext/object/to_query_test.rb
parent3ac731c4d0de940893f9dc486f6bebc9e3240f5a (diff)
parentc420a8daf58cc1544a89ec1cec67005e1c654ad8 (diff)
downloadrails-6924f848c45897004ba9cc4f96c032286dcce346.tar.gz
rails-6924f848c45897004ba9cc4f96c032286dcce346.tar.bz2
rails-6924f848c45897004ba9cc4f96c032286dcce346.zip
Merge pull request #15629 from akshay-vishnoi/test-to_param
Define Hash#to_query and set Hash#to_param as alias to it; with test cases
Diffstat (limited to 'activesupport/test/core_ext/object/to_query_test.rb')
-rw-r--r--activesupport/test/core_ext/object/to_query_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/object/to_query_test.rb b/activesupport/test/core_ext/object/to_query_test.rb
index 47220e9509..09cab3ed35 100644
--- a/activesupport/test/core_ext/object/to_query_test.rb
+++ b/activesupport/test/core_ext/object/to_query_test.rb
@@ -65,6 +65,16 @@ class ToQueryTest < ActiveSupport::TestCase
{a: [], b: 3}
end
+ def test_hash_with_namespace
+ hash = { name: 'Nakshay', nationality: 'Indian' }
+ assert_equal "user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian", hash.to_query('user')
+ end
+
+ def test_hash_sorted_lexicographically
+ hash = { type: 'human', name: 'Nakshay' }
+ assert_equal "name=Nakshay&type=human", hash.to_query
+ end
+
private
def assert_query_equal(expected, actual)
assert_equal expected.split('&'), actual.to_query.split('&')