mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added as_json method for multibyte strings
This commit is contained in:
parent
c4469e6c39
commit
705a1d5b88
2 changed files with 7 additions and 0 deletions
|
@ -188,6 +188,10 @@ module ActiveSupport #:nodoc:
|
|||
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 @@ class MultibyteCharsTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue