Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

failing post hook on embedded documents test

  • Loading branch information...
commit 6652b5c6e9fb81654fc88ac470d9231c5c4d7e13 1 parent dbe3124
@jeromegn jeromegn authored aheckmann committed
Showing with 49 additions and 0 deletions.
  1. +49 −0 test/model.test.js
View
49 test/model.test.js
@@ -3278,5 +3278,54 @@ module.exports = {
});
});
});
+ },
+
+ 'test post hooks on embedded documents': function(){
+ var save = false,
+ init = false,
+ remove = false;
+
+ var EmbeddedSchema = new Schema({
+ title : String
+ });
+
+ var ParentSchema = new Schema({
+ embeds : [EmbeddedSchema]
+ });
+
+ EmbeddedSchema.post('save', function(next){
+ save = true;
+ });
+
+ // Don't know how to test those on a embedded document.
+ /*
+
+ EmbeddedSchema.post('init', function () {
+ init = true;
+ });
+
+ EmbeddedSchema.post('remove', function () {
+ remove = true;
+ });
+
+ */
+
+ mongoose.model('Parent', ParentSchema);
+
+ var db = start(),
+ Parent = db.model('Parent');
+
+ var parent = new Parent();
+
+ parent.embeds.push({title: 'Testing post hooks for embedded docs'});
+
+ parent.save(function(err){
+ process.nextTick(function () {
+ should.strictEqual(err, null);
+ save.should.be.true;
+ db.close();
+ });
+ });
}
+
};
Please sign in to comment.
Something went wrong with that request. Please try again.