Skip to content
Browse files

confirm gh-531 fix

closes #531
  • Loading branch information...
1 parent 8c61503 commit 3e97790b1afcc82fd810ef7bedd0d96dc35b2e39 @aheckmann aheckmann committed
Showing with 13 additions and 9 deletions.
  1. +13 −9 test/types.document.test.js
View
22 test/types.document.test.js
@@ -119,7 +119,7 @@ describe('types.document', function(){
assert.strictEqual(true, m.__id !== m2.__id);
});
- it('Subdocument#remove', function (done) {
+ it('Subdocument#remove (gh-531)', function (done) {
var db = start();
var Movie = db.model('Movie');
@@ -134,7 +134,6 @@ describe('types.document', function(){
super8.ratings.push({ stars: 8, _id: id2 });
super8.ratings.push({ stars: 7, _id: id3 });
super8.ratings.push({ stars: 6, _id: id4 });
- //console.error('pre save', super8);
super8.save(function (err) {
assert.ifError(err);
@@ -162,25 +161,30 @@ describe('types.document', function(){
assert.equal(movie.ratings.id(id3).stars.valueOf(), 4);
assert.equal(movie.ratings.id(id4).stars.valueOf(), 3);
- //console.error('after save + findbyId', movie);
-
movie.ratings.id(id1).stars = 2;
movie.ratings.id(id3).remove();
movie.ratings.id(id4).stars = 1;
- //console.error('after modified', movie);
-
movie.save(function (err) {
assert.ifError(err);
Movie.findById(super8._id, function (err, movie) {
- db.close();
assert.ifError(err);
assert.equal(movie.ratings.length,2);
assert.equal(movie.ratings.id(id1).stars.valueOf(), 2);
assert.equal(movie.ratings.id(id4).stars.valueOf(), 1);
- //console.error('after resave + findById', movie);
- done();
+
+ // gh-531
+ movie.ratings[0].remove();
+ movie.ratings[0].remove();
+ movie.save(function (err) {
+ Movie.findById(super8._id, function (err, movie) {
+ db.close();
+ assert.ifError(err);
+ assert.equal(0, movie.ratings.length);
+ done();
+ });
+ });
});
});
});

0 comments on commit 3e97790

Please sign in to comment.
Something went wrong with that request. Please try again.