Permalink
Browse files

Added failing test for GH-267

  • Loading branch information...
1 parent 4aa1003 commit 25cbc9a54924b5656cd5915f2ff989c1ac5add86 @bnoguchi bnoguchi committed Mar 23, 2011
Showing with 21 additions and 0 deletions.
  1. +21 −0 test/model.test.js
View
@@ -1828,6 +1828,27 @@ module.exports = {
});
});
},
+
+ // GH-267
+ 'saving an embedded document twice should not push that doc onto the parent doc twice': function () {
+ var db = start()
+ , BlogPost = db.model('BlogPost', collection)
+ , post = new BlogPost();
+
+ post.comments.push({title: 'woot'});
+ post.save( function (err) {
+ should.strictEqual(err, null);
+ post.save( function (err) {
+ should.strictEqual(err, null);
+ BlogPost.findById(post.id, function (err, found) {
+ db.close();
+ should.strictEqual(err, null);
+ found.comments.should.have.length(1);
+ });
+ });
+ });
+ },
+
'test filtering an embedded array by the id shortcut function': function () {
var db = start()
, BlogPost = db.model('BlogPost', collection);

0 comments on commit 25cbc9a

Please sign in to comment.