diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/object/to_param_test.rb | 11 | ||||
-rw-r--r-- | activesupport/test/core_ext/object/to_query_test.rb | 9 |
2 files changed, 9 insertions, 11 deletions
diff --git a/activesupport/test/core_ext/object/to_param_test.rb b/activesupport/test/core_ext/object/to_param_test.rb index eae68ed184..bd7c6c422a 100644 --- a/activesupport/test/core_ext/object/to_param_test.rb +++ b/activesupport/test/core_ext/object/to_param_test.rb @@ -1,6 +1,5 @@ require 'abstract_unit' require 'active_support/core_ext/object/to_param' -require 'active_support/core_ext/object/to_query' class ToParamTest < ActiveSupport::TestCase def test_object @@ -17,14 +16,4 @@ class ToParamTest < ActiveSupport::TestCase assert_equal true, true.to_param assert_equal false, false.to_param end - - def test_nested_empty_hash - hash1 = {a: 1, b: {c: 3, d: {}}}.to_param - hash2 = {p: 12, b: {c: 3, e: nil, f: ''}}.to_param - hash3 = {b: {c: 3, k: {}, f: '' }}.to_param - - assert_equal 'a=1&b[c]=3&b[d]=', CGI::unescape(hash1) - assert_equal 'b[c]=3&b[e]=&b[f]=&p=12', CGI::unescape(hash2) - assert_equal 'b[c]=3&b[f]=&b[k]=', CGI::unescape(hash3) - end end diff --git a/activesupport/test/core_ext/object/to_query_test.rb b/activesupport/test/core_ext/object/to_query_test.rb index 92f996f9a4..a53d7781f9 100644 --- a/activesupport/test/core_ext/object/to_query_test.rb +++ b/activesupport/test/core_ext/object/to_query_test.rb @@ -46,6 +46,15 @@ class ToQueryTest < ActiveSupport::TestCase :person => {:id => [20, 10]} end + def test_nested_empty_hash + assert_query_equal 'a=1&b%5Bc%5D=3&b%5Bd%5D=', + { a: 1, b: { c: 3, d: {} } } + assert_query_equal 'b%5Bc%5D=3&b%5Be%5D=&b%5Bf%5D=&p=12', + { p: 12, b: { c: 3, e: nil, f: '' } } + assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=&b%5Bk%5D=', + { b: { c: 3, k: {}, f: '' } } + end + private def assert_query_equal(expected, actual) assert_equal expected.split('&'), actual.to_query.split('&') |