Skip to content

Commit 5e58d83

Browse files
committedNov 9, 2015
repro; #3549
1 parent 68e394d commit 5e58d83

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
 

‎test/model.update.test.js

+25
Original file line numberDiff line numberDiff line change
@@ -1623,4 +1623,29 @@ describe('model: update:', function() {
16231623

16241624
db.close(done);
16251625
});
1626+
1627+
it('middleware update with exec (gh-3549)', function(done) {
1628+
var db = start();
1629+
1630+
var Schema = mongoose.Schema({ name: String });
1631+
1632+
Schema.pre('update', function(next) {
1633+
this.update({ name: 'Val' });
1634+
next();
1635+
});
1636+
1637+
var Model = db.model('gh3549', Schema);
1638+
1639+
Model.create({}, function(error, doc) {
1640+
assert.ifError(error);
1641+
Model.update({ _id: doc._id }, { name: 'test' }).exec(function(error) {
1642+
assert.ifError(error);
1643+
Model.findOne({ _id: doc._id }, function(error, doc) {
1644+
assert.ifError(error);
1645+
assert.equal(doc.name, 'Val');
1646+
db.close(done);
1647+
});
1648+
});
1649+
});
1650+
});
16261651
});

0 commit comments

Comments
 (0)
Please sign in to comment.