aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/json/encoding_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-08 21:03:37 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-08 21:03:37 -0300
commitc910388587220e962682b0b9187e79b8f1641c17 (patch)
tree2bc3b010fc8c5d14952da3336fd554aaca91e8eb /activesupport/test/json/encoding_test.rb
parent8218a46adb5d2c360f54d5680966f9d78f5aa4bc (diff)
downloadrails-c910388587220e962682b0b9187e79b8f1641c17.tar.gz
rails-c910388587220e962682b0b9187e79b8f1641c17.tar.bz2
rails-c910388587220e962682b0b9187e79b8f1641c17.zip
Revert "Remove unicode character encoding from ActiveSupport::JSON.encode"
This reverts commit 815a9431ab61376a7e8e1bdff21f87bc557992f8. Conflicts: activesupport/test/json/encoding_test.rb Reason: This was causing a regression where the resulting string is always returning UTF-8. Also it changes the behavior of this method on a stable release. Fixes #9498.
Diffstat (limited to 'activesupport/test/json/encoding_test.rb')
-rw-r--r--activesupport/test/json/encoding_test.rb24
1 files changed, 9 insertions, 15 deletions
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb
index e4e13c3f25..67b648e6db 100644
--- a/activesupport/test/json/encoding_test.rb
+++ b/activesupport/test/json/encoding_test.rb
@@ -100,11 +100,11 @@ class TestJSONEncoding < Test::Unit::TestCase
def test_utf8_string_encoded_properly_when_kcode_is_utf8
with_kcode 'UTF8' do
result = ActiveSupport::JSON.encode('€2.99')
- assert_equal '"€2.99"', result
+ assert_equal '"\\u20ac2.99"', result
assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
result = ActiveSupport::JSON.encode('✎☺')
- assert_equal '"✎☺"', result
+ assert_equal '"\\u270e\\u263a"', result
assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
end
end
@@ -113,22 +113,16 @@ class TestJSONEncoding < Test::Unit::TestCase
def test_non_utf8_string_transcodes
s = '二'.encode('Shift_JIS')
result = ActiveSupport::JSON.encode(s)
- assert_equal '"二"', result
+ assert_equal '"\\u4e8c"', result
assert_equal Encoding::UTF_8, result.encoding
end
- end
-
- def test_wide_utf8_chars
- w = '𠜎'
- result = ActiveSupport::JSON.encode(w)
- assert_equal '"𠜎"', result
- end
- def test_wide_utf8_roundtrip
- hash = { :string => "𐒑" }
- json = ActiveSupport::JSON.encode(hash)
- decoded_hash = ActiveSupport::JSON.decode(json)
- assert_equal "𐒑", decoded_hash['string']
+ def test_utf8_hash_key
+ w = { '𠜎' => 'a' }
+ result = ActiveSupport::JSON.encode(w)
+ assert_equal '{"\\u070e":"a"}', result
+ assert_equal Encoding::US_ASCII, result.encoding
+ end
end
def test_exception_raised_when_encoding_circular_reference_in_array