Skip to content

Commit

Permalink
test(document): repro #5215
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed May 9, 2017
1 parent 6942c34 commit 9f24e99
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4075,6 +4075,27 @@ describe('document', function() {
});
});

it('handles errors in subdoc pre validate (gh-5215)', function(done) {
var childSchema = new mongoose.Schema({});

childSchema.pre('validate', function(next) {
next(new Error('child pre validate'))
});

var parentSchema = new mongoose.Schema({
child: childSchema
});

var Parent = db.model('gh5215', parentSchema);

Parent.create({ child: {} }, function(error) {
assert.ok(error);
assert.ok(error.errors['child']);
assert.equal(error.errors['child'].message, 'child pre validate');
done();
});
});

it('modify multiple subdoc paths (gh-4405)', function(done) {
var ChildObjectSchema = new Schema({
childProperty1: String,
Expand Down

0 comments on commit 9f24e99

Please sign in to comment.