Commit e8e778f4 by jsa

use yajl for json serialization

parent 8f0c6e45
...@@ -114,6 +114,28 @@ end ...@@ -114,6 +114,28 @@ end
Mongoid.identity_map_enabled = true Mongoid.identity_map_enabled = true
use Rack::Mongoid::Middleware::IdentityMap use Rack::Mongoid::Middleware::IdentityMap
# use yajl implementation for to_json.
# https://github.com/brianmario/yajl-ruby#json-gem-compatibility-api
#
# In addition to performance advantages over the standard JSON gem,
# this avoids a bug with non-BMP characters. For more info see:
# https://github.com/rails/rails/issues/3727
require 'yajl/json_gem'
# patch json serialization of ObjectIds to work properly with yajl.
# See https://groups.google.com/forum/#!topic/mongoid/MaXFVw7D_4s
module Moped
module BSON
class ObjectId
def to_json
self.to_s.to_json
end
end
end
end
# these files must be required in order # these files must be required in order
require './api/search' require './api/search'
require './api/commentables' require './api/commentables'
......
...@@ -14,7 +14,6 @@ shared_examples "unicode data" do ...@@ -14,7 +14,6 @@ shared_examples "unicode data" do
end end
it "can handle non-BMP data" do it "can handle non-BMP data" do
pending("circumventing a bug in ActiveSupport's JSON encoding of non-BMP characters")
test_unicode_data("𝕋𝕙𝕚𝕤 𝕡𝕠𝕤𝕥 𝕔𝕠𝕟𝕥𝕒𝕚𝕟𝕤 𝕔𝕙𝕒𝕣𝕒𝕔𝕥𝕖𝕣𝕤 𝕠𝕦𝕥𝕤𝕚𝕕𝕖 𝕥𝕙𝕖 𝔹𝕄ℙ") test_unicode_data("𝕋𝕙𝕚𝕤 𝕡𝕠𝕤𝕥 𝕔𝕠𝕟𝕥𝕒𝕚𝕟𝕤 𝕔𝕙𝕒𝕣𝕒𝕔𝕥𝕖𝕣𝕤 𝕠𝕦𝕥𝕤𝕚𝕕𝕖 𝕥𝕙𝕖 𝔹𝕄ℙ")
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment