@@ -239,6 +239,51 @@ describe('schemas', () => {
239
239
} ) ;
240
240
} ) ;
241
241
242
+ it ( 'ensure refresh cache after creating a class' , async done => {
243
+ await request ( {
244
+ url : 'http://localhost:8378/1/schemas' ,
245
+ method : 'POST' ,
246
+ headers : masterKeyHeaders ,
247
+ json : true ,
248
+ body : {
249
+ className : 'A' ,
250
+ } ,
251
+ } ) ;
252
+ const response = await request ( {
253
+ url : 'http://localhost:8378/1/schemas' ,
254
+ method : 'GET' ,
255
+ headers : masterKeyHeaders ,
256
+ json : true ,
257
+ } ) ;
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
+
242
287
it ( 'responds with a single schema' , done => {
243
288
const obj = hasAllPODobject ( ) ;
244
289
obj . save ( ) . then ( ( ) => {
@@ -1507,6 +1552,43 @@ describe('schemas', () => {
1507
1552
} ) ;
1508
1553
} ) ;
1509
1554
1555
+ it ( 'ensure refresh cache after deleting a class' , async done => {
1556
+ await request ( {
1557
+ url : 'http://localhost:8378/1/schemas' ,
1558
+ method : 'POST' ,
1559
+ headers : masterKeyHeaders ,
1560
+ json : true ,
1561
+ body : {
1562
+ className : 'A' ,
1563
+ } ,
1564
+ } ) ;
1565
+ await request ( {
1566
+ method : 'DELETE' ,
1567
+ url : 'http://localhost:8378/1/schemas/A' ,
1568
+ headers : masterKeyHeaders ,
1569
+ json : true ,
1570
+ } ) ;
1571
+ const response = await request ( {
1572
+ url : 'http://localhost:8378/1/schemas' ,
1573
+ method : 'GET' ,
1574
+ headers : masterKeyHeaders ,
1575
+ json : true ,
1576
+ } ) ;
1577
+ const expected = {
1578
+ results : [ userSchema , roleSchema ] ,
1579
+ } ;
1580
+ expect (
1581
+ response . data . results
1582
+ . sort ( ( s1 , s2 ) => s1 . className . localeCompare ( s2 . className ) )
1583
+ . map ( s => {
1584
+ const withoutIndexes = Object . assign ( { } , s ) ;
1585
+ delete withoutIndexes . indexes ;
1586
+ return withoutIndexes ;
1587
+ } )
1588
+ ) . toEqual ( expected . results . sort ( ( s1 , s2 ) => s1 . className . localeCompare ( s2 . className ) ) ) ;
1589
+ done ( ) ;
1590
+ } ) ;
1591
+
1510
1592
it ( 'deletes collections including join tables' , done => {
1511
1593
const obj = new Parse . Object ( 'MyClass' ) ;
1512
1594
obj . set ( 'data' , 'data' ) ;
0 commit comments