Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add test for ref casting

  • Loading branch information...
commit acd756b600d08427ed974858b2392dee45ba6f27 1 parent 1406d00
@aheckmann aheckmann authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 test/model.ref.test.js
View
10 test/model.ref.test.js
@@ -9,6 +9,7 @@ var start = require('./common')
, random = require('../lib/utils').random
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
+ , DocObjectId = mongoose.Types.ObjectId
/**
* Setup.
@@ -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.
Something went wrong with that request. Please try again.