Skip to content

Commit

Permalink
test(document): repro #7302
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jan 20, 2019
1 parent 2370f97 commit 0e1772f
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 @@ -4984,6 +4984,27 @@ describe('document', function() {
done();
});

it('Handles setting populated path set via `Document#populate()` (gh-7302)', function() {
var authorSchema = new Schema({ name: String });
var bookSchema = new Schema({
author: { type: mongoose.Schema.Types.ObjectId, ref: 'gh7302_Author' }
});

var Author = db.model('gh7302_Author', authorSchema);
var Book = db.model('gh7302_Book', bookSchema);

return Author.create({ name: 'Victor Hugo' }).
then(author => Book.create({ author: author._id })).
then(() => Book.findOne()).
then(doc => doc.populate('author').execPopulate()).
then(doc => {
doc.author = {};
assert.ok(!doc.author.name);
assert.ifError(doc.validateSync());
});
});


it('Single nested subdocs using discriminator can be modified (gh-5693)', function(done) {
var eventSchema = new Schema({ message: String }, {
discriminatorKey: 'kind',
Expand Down

0 comments on commit 0e1772f

Please sign in to comment.