Skip to content

Commit

Permalink
add test for ref casting
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Sep 2, 2011
1 parent 1406d00 commit acd756b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/model.ref.test.js
Expand Up @@ -9,6 +9,7 @@ var start = require('./common')
, random = require('../lib/utils').random
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
, DocObjectId = mongoose.Types.ObjectId

/**
* Setup.
Expand Down Expand Up @@ -615,5 +616,14 @@ module.exports = {
setTimeout(function () {
worked.should.be.true;
}, 1700);
},

'refs should cast to ObjectId from hexstrings': function () {
var BP = mongoose.model('RefBlogPost', BlogPost);
var bp = new BP;
bp._creator = new DocObjectId().toString();
bp._creator.should.be.an.instanceof(DocObjectId);
bp.set('_creator', new DocObjectId().toString());
bp._creator.should.be.an.instanceof(DocObjectId);
}
};

0 comments on commit acd756b

Please sign in to comment.