File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -4984,6 +4984,27 @@ describe('document', function() {
4984
4984
done ( ) ;
4985
4985
} ) ;
4986
4986
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
+
4987
5008
it ( 'Single nested subdocs using discriminator can be modified (gh-5693)' , function ( done ) {
4988
5009
var eventSchema = new Schema ( { message : String } , {
4989
5010
discriminatorKey : 'kind' ,
You can’t perform that action at this time.
0 commit comments