minor: fix for to_json
This commit is contained in:
parent
2121d6c809
commit
bb7cb79030
|
@ -140,7 +140,7 @@ module BSON
|
|||
# but lacks an ObjectID type, this JSON format encodes the type using an $oid key.
|
||||
#
|
||||
# @return [String] the object id represented as MongoDB extended JSON.
|
||||
def to_json(escaped=false)
|
||||
def to_json(*a)
|
||||
"{\"$oid\": \"#{to_s}\"}"
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
require 'test/test_helper'
|
||||
require 'rubygems'
|
||||
require 'json'
|
||||
|
||||
class JSONTest < Test::Unit::TestCase
|
||||
|
||||
include Mongo
|
||||
include BSON
|
||||
|
||||
def test_object_id_as_json
|
||||
id = ObjectID.new
|
||||
obj = {'_id' => id}
|
||||
assert_equal "{\"_id\":{\"$oid\": \"#{id.to_s}\"}}", obj.to_json
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue