aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/object/to_param_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/object/to_param_test.rb')
-rw-r--r--activesupport/test/core_ext/object/to_param_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/object/to_param_test.rb b/activesupport/test/core_ext/object/to_param_test.rb
index bd7c6c422a..eae68ed184 100644
--- a/activesupport/test/core_ext/object/to_param_test.rb
+++ b/activesupport/test/core_ext/object/to_param_test.rb
@@ -1,5 +1,6 @@
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
@@ -16,4 +17,14 @@ 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