Skip to content

Commit 07d8edb

Browse files
committed
test(document): repro #5703
1 parent 3597079 commit 07d8edb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/document.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,35 @@ describe('document', function() {
913913
});
914914
});
915915
});
916+
917+
it('populate on nested path (gh-5703)', function() {
918+
var toySchema = new mongoose.Schema({ color: String });
919+
var Toy = db.model('gh5703', toySchema);
920+
921+
var childSchema = new mongoose.Schema({
922+
name: String,
923+
values: {
924+
toy: { type: mongoose.Schema.Types.ObjectId, ref: 'gh5703' }
925+
}
926+
});
927+
var Child = db.model('gh5703_0', childSchema);
928+
929+
return Toy.create({ color: 'blue' }).
930+
then(function(toy) {
931+
return Child.create({ values: { toy: toy._id } });
932+
}).
933+
then(function(child) {
934+
return Child.findById(child._id);
935+
}).
936+
then(function(child) {
937+
return child.values.populate('toy').execPopulate().then(function() {
938+
return child;
939+
});
940+
}).
941+
then(function(child) {
942+
assert.equal(child.values.toy.color, 'blue');
943+
});
944+
});
916945
});
917946

918947
describe('#update', function() {

0 commit comments

Comments
 (0)