@@ -712,7 +712,7 @@ describe('Cloud Code', () => {
712
712
done ( ) ;
713
713
} ) ;
714
714
} ) ;
715
-
715
+
716
716
it ( 'beforeSave change propagates through the afterSave #1931' , ( done ) => {
717
717
Parse . Cloud . beforeSave ( 'ChangingObject' , function ( request , response ) {
718
718
request . object . unset ( 'file' ) ;
@@ -1044,7 +1044,7 @@ describe('Cloud Code', () => {
1044
1044
res . success ( ) ;
1045
1045
} ) ;
1046
1046
} ) . not . toThrow ( ) ;
1047
-
1047
+
1048
1048
rp . post ( {
1049
1049
url : 'http://localhost:8378/1/jobs/myJob' ,
1050
1050
headers : {
@@ -1065,7 +1065,7 @@ describe('Cloud Code', () => {
1065
1065
res . success ( ) ;
1066
1066
} ) ;
1067
1067
} ) . not . toThrow ( ) ;
1068
-
1068
+
1069
1069
rp . post ( {
1070
1070
url : 'http://localhost:8378/1/jobs/myJob' ,
1071
1071
headers : {
@@ -1094,7 +1094,7 @@ describe('Cloud Code', () => {
1094
1094
done ( ) ;
1095
1095
} ) ;
1096
1096
} ) . not . toThrow ( ) ;
1097
-
1097
+
1098
1098
rp . post ( {
1099
1099
url : 'http://localhost:8378/1/jobs/myJob' ,
1100
1100
headers : {
@@ -1121,7 +1121,7 @@ describe('Cloud Code', () => {
1121
1121
done ( ) ;
1122
1122
} ) ;
1123
1123
} ) . not . toThrow ( ) ;
1124
-
1124
+
1125
1125
rp . post ( {
1126
1126
url : `http://${ Parse . applicationId } :${ Parse . masterKey } @localhost:8378/1/jobs/myJob` ,
1127
1127
} ) . then ( ( ) => {
@@ -1152,7 +1152,7 @@ describe('Cloud Code', () => {
1152
1152
done ( ) ;
1153
1153
} ) ;
1154
1154
} ) ;
1155
-
1155
+
1156
1156
rp . post ( {
1157
1157
url : 'http://localhost:8378/1/jobs/myJob' ,
1158
1158
headers : {
@@ -1179,7 +1179,7 @@ describe('Cloud Code', () => {
1179
1179
done ( ) ;
1180
1180
} ) ;
1181
1181
} ) ;
1182
-
1182
+
1183
1183
rp . post ( {
1184
1184
url : 'http://localhost:8378/1/jobs/myJob' ,
1185
1185
headers : {
@@ -1434,5 +1434,40 @@ describe('afterFind hooks', () => {
1434
1434
} ) ;
1435
1435
} ) ;
1436
1436
1437
- } ) ;
1437
+ it ( 'should alter select' , ( done ) => {
1438
+ Parse . Cloud . beforeFind ( 'MyObject' , ( req ) => {
1439
+ req . query . select ( 'white' ) ;
1440
+ return req . query ;
1441
+ } ) ;
1442
+
1443
+ const obj0 = new Parse . Object ( 'MyObject' )
1444
+ . set ( 'white' , true )
1445
+ . set ( 'black' , true ) ;
1446
+ obj0 . save ( )
1447
+ . then ( ( ) => {
1448
+ new Parse . Query ( 'MyObject' )
1449
+ . first ( )
1450
+ . then ( result => {
1451
+ expect ( result . get ( 'white' ) ) . toBe ( true ) ;
1452
+ expect ( result . get ( 'black' ) ) . toBe ( undefined ) ;
1453
+ done ( ) ;
1454
+ } ) ;
1455
+ } ) ;
1456
+ } ) ;
1438
1457
1458
+ it ( 'should not alter select' , ( done ) => {
1459
+ const obj0 = new Parse . Object ( 'MyObject' )
1460
+ . set ( 'white' , true )
1461
+ . set ( 'black' , true ) ;
1462
+ obj0 . save ( )
1463
+ . then ( ( ) => {
1464
+ new Parse . Query ( 'MyObject' )
1465
+ . first ( )
1466
+ . then ( result => {
1467
+ expect ( result . get ( 'white' ) ) . toBe ( true ) ;
1468
+ expect ( result . get ( 'black' ) ) . toBe ( true ) ;
1469
+ done ( ) ;
1470
+ } ) ;
1471
+ } ) ;
1472
+ } ) ;
1473
+ } ) ;
0 commit comments