Skip to content

Commit

Permalink
test(document): repro #5703
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 19, 2017
1 parent 3597079 commit 07d8edb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,35 @@ describe('document', function() {
});
});
});

it('populate on nested path (gh-5703)', function() {
var toySchema = new mongoose.Schema({ color: String });
var Toy = db.model('gh5703', toySchema);

var childSchema = new mongoose.Schema({
name: String,
values: {
toy: { type: mongoose.Schema.Types.ObjectId, ref: 'gh5703' }
}
});
var Child = db.model('gh5703_0', childSchema);

return Toy.create({ color: 'blue' }).
then(function(toy) {
return Child.create({ values: { toy: toy._id } });
}).
then(function(child) {
return Child.findById(child._id);
}).
then(function(child) {
return child.values.populate('toy').execPopulate().then(function() {
return child;
});
}).
then(function(child) {
assert.equal(child.values.toy.color, 'blue');
});
});
});

describe('#update', function() {
Expand Down

0 comments on commit 07d8edb

Please sign in to comment.