Skip to content

Commit 0e1772f

Browse files
committedJan 20, 2019
test(document): repro #7302
1 parent 2370f97 commit 0e1772f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎test/document.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -4984,6 +4984,27 @@ describe('document', function() {
49844984
done();
49854985
});
49864986

4987+
it('Handles setting populated path set via `Document#populate()` (gh-7302)', function() {
4988+
var authorSchema = new Schema({ name: String });
4989+
var bookSchema = new Schema({
4990+
author: { type: mongoose.Schema.Types.ObjectId, ref: 'gh7302_Author' }
4991+
});
4992+
4993+
var Author = db.model('gh7302_Author', authorSchema);
4994+
var Book = db.model('gh7302_Book', bookSchema);
4995+
4996+
return Author.create({ name: 'Victor Hugo' }).
4997+
then(author => Book.create({ author: author._id })).
4998+
then(() => Book.findOne()).
4999+
then(doc => doc.populate('author').execPopulate()).
5000+
then(doc => {
5001+
doc.author = {};
5002+
assert.ok(!doc.author.name);
5003+
assert.ifError(doc.validateSync());
5004+
});
5005+
});
5006+
5007+
49875008
it('Single nested subdocs using discriminator can be modified (gh-5693)', function(done) {
49885009
var eventSchema = new Schema({ message: String }, {
49895010
discriminatorKey: 'kind',

0 commit comments

Comments
 (0)
Please sign in to comment.