aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-09-28 00:32:20 +0200
committerXavier Noria <fxn@hashref.com>2010-09-28 00:32:20 +0200
commit10dec0e65e1f4d87f411b4361045eba86b121be9 (patch)
tree36d90e5f9b40c4d48d344481a895383fc7e0277c /activesupport/test/core_ext
parentf22b40a8f223e0b2f5194b6f3ce24cafd5cd3a05 (diff)
downloadrails-10dec0e65e1f4d87f411b4361045eba86b121be9.tar.gz
rails-10dec0e65e1f4d87f411b4361045eba86b121be9.tar.bz2
rails-10dec0e65e1f4d87f411b4361045eba86b121be9.zip
let Hash#to_param and Hash#to_query sort again
This was a regression introduced in 5c858220085dc4ddc1bec496747059dfbe32f1da. We bring sorting back because people rely on it, eg for constructing consistent cache keys.
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index e5438745e0..0f35eb9e78 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -462,20 +462,24 @@ class HashExtToParamTests < Test::Unit::TestCase
assert_equal '', {}.to_param
assert_equal 'hello=world', { :hello => "world" }.to_param
assert_equal 'hello=10', { "hello" => 10 }.to_param
- assert_equal 'hello=world&say_bye=true', ActiveSupport::OrderedHash[:hello, "world", "say_bye", true].to_param
+ assert_equal 'hello=world&say_bye=true', {:hello => "world", "say_bye" => true}.to_param
end
def test_number_hash
- assert_equal '10=20&30=40&50=60', ActiveSupport::OrderedHash[10, 20, 30, 40, 50, 60].to_param
+ assert_equal '10=20&30=40&50=60', {10 => 20, 30 => 40, 50 => 60}.to_param
end
def test_to_param_hash
- assert_equal 'custom=param-1&custom2=param2-1', ActiveSupport::OrderedHash[ToParam.new('custom'), ToParam.new('param'), ToParam.new('custom2'), ToParam.new('param2')].to_param
+ assert_equal 'custom2=param2-1&custom=param-1', {ToParam.new('custom') => ToParam.new('param'), ToParam.new('custom2') => ToParam.new('param2')}.to_param
end
def test_to_param_hash_escapes_its_keys_and_values
assert_equal 'param+1=A+string+with+%2F+characters+%26+that+should+be+%3F+escaped', { 'param 1' => 'A string with / characters & that should be ? escaped' }.to_param
end
+
+ def test_to_param_orders_by_key_in_ascending_order
+ assert_equal 'a=2&b=1&c=0', ActiveSupport::OrderedHash[*%w(b 1 c 0 a 2)].to_param
+ end
end
class HashToXmlTest < Test::Unit::TestCase