Skip to content

Commit

Permalink
minor: fix for to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
banker committed Jul 7, 2010
1 parent 2121d6c commit bb7cb79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bson/types/objectid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def inspect
# 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

Expand Down
16 changes: 16 additions & 0 deletions test/mongo_bson/json_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bb7cb79

Please sign in to comment.