Permalink
Browse files

Added as_json method for multibyte strings

  • Loading branch information...
1 parent c4469e6 commit 705a1d5b881604364a6891d16ae0ae43592b1c9c Dmitriy Vorotilin committed Jan 31, 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 705a1d5

Please sign in to comment.