Skip to content

Commit

Permalink
test(document): repro #8149
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 12, 2019
1 parent 6e86500 commit 74f558c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/document.test.js
Expand Up @@ -7835,6 +7835,22 @@ describe('document', function() {
assert.equal(fromDb2.test, 'after');
});
});

it('immutable with strict mode (gh-8149)', function() {
return co(function*() {
const schema = new mongoose.Schema({
name: String,
yearOfBirth: { type: Number, immutable: true }
}, { strict: 'throw' });
const Person = db.model('gh8149', schema);
const joe = yield Person.create({ name: 'Joe', yearOfBirth: 2001 });

joe.set({ yearOfBirth: 2002 });
const err = yield joe.save().then(() => null, err => err);
assert.ok(err);
assert.equal(err.errors['yearOfBirth'].name, 'StrictModeError');
});
});
});

it('consistent post order traversal for array subdocs (gh-7929)', function() {
Expand Down

0 comments on commit 74f558c

Please sign in to comment.