Added as_json method for multibyte strings

This commit is contained in:
Dmitriy Vorotilin 2012-02-01 02:01:00 +04:00
parent c4469e6c39
commit 705a1d5b88
2 changed files with 7 additions and 0 deletions

@ -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