@@ -239,6 +239,53 @@ describe('schemas', () => {
239
239
} ) ;
240
240
} ) ;
241
241
242
+ it ( 'ensure refresh cache after creating a class' , done => {
243
+ request ( {
244
+ url : 'http://localhost:8378/1/schemas' ,
245
+ method : 'POST' ,
246
+ headers : masterKeyHeaders ,
247
+ json : true ,
248
+ body : {
249
+ className : 'A' ,
250
+ } ,
251
+ } ) . then ( ( ) => {
252
+ request ( {
253
+ url : 'http://localhost:8378/1/schemas' ,
254
+ method : 'GET' ,
255
+ headers : masterKeyHeaders ,
256
+ json : true ,
257
+ } ) . then ( response => {
258
+ const expected = {
259
+ results : [
260
+ userSchema ,
261
+ roleSchema ,
262
+ {
263
+ className : 'A' ,
264
+ fields : {
265
+ //Default fields
266
+ ACL : { type : 'ACL' } ,
267
+ createdAt : { type : 'Date' } ,
268
+ updatedAt : { type : 'Date' } ,
269
+ objectId : { type : 'String' } ,
270
+ } ,
271
+ classLevelPermissions : defaultClassLevelPermissions ,
272
+ } ,
273
+ ] ,
274
+ } ;
275
+ expect (
276
+ response . data . results
277
+ . sort ( ( s1 , s2 ) => s1 . className . localeCompare ( s2 . className ) )
278
+ . map ( s => {
279
+ const withoutIndexes = Object . assign ( { } , s ) ;
280
+ delete withoutIndexes . indexes ;
281
+ return withoutIndexes ;
282
+ } )
283
+ ) . toEqual ( expected . results . sort ( ( s1 , s2 ) => s1 . className . localeCompare ( s2 . className ) ) ) ;
284
+ done ( ) ;
285
+ } ) ;
286
+ } ) ;
287
+ } ) ;
288
+
242
289
it ( 'responds with a single schema' , done => {
243
290
const obj = hasAllPODobject ( ) ;
244
291
obj . save ( ) . then ( ( ) => {
@@ -1507,6 +1554,46 @@ describe('schemas', () => {
1507
1554
} ) ;
1508
1555
} ) ;
1509
1556
1557
+ it ( 'ensure refresh cache after deleting a class' , done => {
1558
+ request ( {
1559
+ url : 'http://localhost:8378/1/schemas' ,
1560
+ method : 'POST' ,
1561
+ headers : masterKeyHeaders ,
1562
+ json : true ,
1563
+ body : {
1564
+ className : 'A' ,
1565
+ } ,
1566
+ } ) . then ( ( ) => {
1567
+ request ( {
1568
+ method : 'DELETE' ,
1569
+ url : 'http://localhost:8378/1/schemas/A' ,
1570
+ headers : masterKeyHeaders ,
1571
+ json : true ,
1572
+ } ) . then ( ( ) => {
1573
+ request ( {
1574
+ url : 'http://localhost:8378/1/schemas' ,
1575
+ method : 'GET' ,
1576
+ headers : masterKeyHeaders ,
1577
+ json : true ,
1578
+ } ) . then ( response => {
1579
+ const expected = {
1580
+ results : [ userSchema , roleSchema ] ,
1581
+ } ;
1582
+ expect (
1583
+ response . data . results
1584
+ . sort ( ( s1 , s2 ) => s1 . className . localeCompare ( s2 . className ) )
1585
+ . map ( s => {
1586
+ const withoutIndexes = Object . assign ( { } , s ) ;
1587
+ delete withoutIndexes . indexes ;
1588
+ return withoutIndexes ;
1589
+ } )
1590
+ ) . toEqual ( expected . results . sort ( ( s1 , s2 ) => s1 . className . localeCompare ( s2 . className ) ) ) ;
1591
+ done ( ) ;
1592
+ } ) ;
1593
+ } ) ;
1594
+ } ) ;
1595
+ } ) ;
1596
+
1510
1597
it ( 'deletes collections including join tables' , done => {
1511
1598
const obj = new Parse . Object ( 'MyClass' ) ;
1512
1599
obj . set ( 'data' , 'data' ) ;
0 commit comments