Permalink
Browse files

Move test to the right file

  • Loading branch information...
rafaelfranca committed Feb 6, 2014
1 parent 326e652 commit 88b064dfae924f28ec4750ea5a3a91b855481546
@@ -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 @@ def test_boolean
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
@@ -46,6 +46,15 @@ def test_array_values_are_not_sorted
: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('&')

0 comments on commit 88b064d

Please sign in to comment.