Permalink
Browse files

Merge pull request #4808 from route/mb_chars_as_json

Added as_json method for multibyte strings
  • Loading branch information...
2 parents d613d60 + 705a1d5 commit 7179fad54d6df46f944ccdb404d02c2ef360d912 @josevalim josevalim committed Feb 1, 2012
@@ -188,6 +188,10 @@ def tidy_bytes(force = false)
chars(Unicode.tidy_bytes(@wrapped_string, force))
end
+ def as_json(options = nil) #:nodoc:
+ to_s.as_json(options)
+ end
+
%w(capitalize downcase reverse tidy_bytes upcase).each do |method|
define_method("#{method}!") do |*args|
@wrapped_string = send(method, *args).to_s
@@ -88,6 +88,9 @@ def test_concatenate_should_return_proxy_instance
assert(('a'.mb_chars << 'b'.mb_chars).kind_of?(@proxy_class))
end
+ def test_should_return_string_as_json
+ assert_equal UNICODE_STRING, @chars.as_json
+ end
end
class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase

0 comments on commit 7179fad

Please sign in to comment.