Skip to content

Commit 0d09476

Browse files
drew-grossflovilmart
authored andcommitted
Cleanup update (#1590)
* destructuring in DB controller * deleteObject in db adapter * Turns out we can't have delete by object ID because of ACLs... * Fix tests * destructure acl * Don't reject with object
1 parent ab827e3 commit 0d09476

10 files changed

+192
-170
lines changed

spec/ParseACL.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ describe('Parse.ACL', () => {
169169
ok(object.get("ACL"));
170170

171171
// Start making requests by the public, which should all fail.
172-
Parse.User.logOut();
173-
174-
// Delete
175-
object.destroy().then(() => {
172+
Parse.User.logOut()
173+
.then(() => object.destroy())
174+
.then(() => {
176175
fail('destroy should fail');
176+
done();
177177
}, error => {
178178
expect(error.code).toEqual(Parse.Error.OBJECT_NOT_FOUND);
179179
done();

spec/ParseAPI.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ describe('miscellaneous', function() {
3939
expect(data.get('password')).toBeUndefined();
4040
done();
4141
}, function(err) {
42-
console.log(err);
4342
fail(err);
43+
done();
4444
});
4545
});
4646

spec/ParseHooks.spec.js

+38-44
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,44 @@ describe('Hooks', () => {
3737
});
3838
});
3939

40-
it("should CRUD a function registration", (done) => {
41-
// Create
42-
Parse.Hooks.createFunction("My-Test-Function", "http://someurl").then((res) => {
43-
expect(res.functionName).toBe("My-Test-Function");
44-
expect(res.url).toBe("http://someurl")
45-
// Find
46-
return Parse.Hooks.getFunction("My-Test-Function");
47-
}, (err) => {
48-
fail(err);
49-
done();
50-
}).then((res) => {
51-
expect(res).not.toBe(null);
52-
expect(res).not.toBe(undefined);
53-
expect(res.url).toBe("http://someurl");
54-
// delete
55-
return Parse.Hooks.updateFunction("My-Test-Function", "http://anotherurl");
56-
}, (err) => {
57-
fail(err);
58-
done();
59-
}).then((res) => {
60-
expect(res.functionName).toBe("My-Test-Function");
61-
expect(res.url).toBe("http://anotherurl")
62-
63-
return Parse.Hooks.deleteFunction("My-Test-Function");
64-
}, (err) => {
65-
fail(err);
66-
done();
67-
}).then((res) => {
68-
// Find again! but should be deleted
69-
return Parse.Hooks.getFunction("My-Test-Function");
70-
}, (err) => {
71-
fail(err);
72-
done();
73-
}).then((res) => {
74-
fail("Should not succeed")
75-
done();
76-
}, (err) => {
77-
expect(err).not.toBe(null);
78-
expect(err).not.toBe(undefined);
79-
expect(err.code).toBe(143);
80-
expect(err.error).toBe("no function named: My-Test-Function is defined")
81-
done();
82-
})
83-
});
40+
it("should CRUD a function registration", (done) => {
41+
// Create
42+
Parse.Hooks.createFunction("My-Test-Function", "http://someurl")
43+
.then(response => {
44+
expect(response.functionName).toBe("My-Test-Function");
45+
expect(response.url).toBe("http://someurl")
46+
// Find
47+
return Parse.Hooks.getFunction("My-Test-Function")
48+
}).then(response => {
49+
expect(response.url).toBe("http://someurl");
50+
return Parse.Hooks.updateFunction("My-Test-Function", "http://anotherurl");
51+
})
52+
.then((res) => {
53+
expect(res.functionName).toBe("My-Test-Function");
54+
expect(res.url).toBe("http://anotherurl")
55+
// delete
56+
return Parse.Hooks.deleteFunction("My-Test-Function")
57+
})
58+
.then((res) => {
59+
// Find again! but should be deleted
60+
return Parse.Hooks.getFunction("My-Test-Function")
61+
.then(res => {
62+
fail("Failed to delete hook")
63+
fail(res)
64+
done();
65+
return Promise.resolve();
66+
}, (err) => {
67+
expect(err.code).toBe(143);
68+
expect(err.error).toBe("no function named: My-Test-Function is defined")
69+
done();
70+
return Promise.resolve();
71+
})
72+
})
73+
.catch(error => {
74+
fail(error);
75+
done();
76+
})
77+
});
8478

8579
it("should CRUD a trigger registration", (done) => {
8680
// Create

spec/PointerPermissions.spec.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe('Pointer Permissions', () => {
4141
done();
4242
});
4343
});
44-
45-
44+
45+
4646
it('should work with write', (done) => {
4747
let config = new Config(Parse.applicationId);
4848
let user = new Parse.User();
@@ -107,7 +107,7 @@ describe('Pointer Permissions', () => {
107107
done();
108108
})
109109
});
110-
110+
111111
it('should let a proper user find', (done) => {
112112
let config = new Config(Parse.applicationId);
113113
let user = new Parse.User();
@@ -137,7 +137,7 @@ describe('Pointer Permissions', () => {
137137
let q = new Parse.Query('AnObject');
138138
return q.find();
139139
}).then((res) => {
140-
expect(res.length).toBe(0);
140+
expect(res.length).toBe(0);
141141
}).then(() => {
142142
return Parse.User.logIn('user2', 'password');
143143
}).then(() => {
@@ -167,7 +167,7 @@ describe('Pointer Permissions', () => {
167167
done();
168168
})
169169
});
170-
170+
171171
it('should not allow creating objects', (done) => {
172172
let config = new Config(Parse.applicationId);
173173
let user = new Parse.User();
@@ -193,7 +193,7 @@ describe('Pointer Permissions', () => {
193193
done();
194194
})
195195
});
196-
196+
197197
it('should handle multiple writeUserFields', (done) => {
198198
let config = new Config(Parse.applicationId);
199199
let user = new Parse.User();
@@ -235,7 +235,7 @@ describe('Pointer Permissions', () => {
235235
done();
236236
})
237237
});
238-
238+
239239
it('should prevent creating pointer permission on missing field', (done) => {
240240
let config = new Config(Parse.applicationId);
241241
config.database.loadSchema().then((schema) => {
@@ -248,7 +248,7 @@ describe('Pointer Permissions', () => {
248248
done();
249249
})
250250
});
251-
251+
252252
it('should prevent creating pointer permission on bad field', (done) => {
253253
let config = new Config(Parse.applicationId);
254254
config.database.loadSchema().then((schema) => {
@@ -261,7 +261,7 @@ describe('Pointer Permissions', () => {
261261
done();
262262
})
263263
});
264-
264+
265265
it('should prevent creating pointer permission on bad field', (done) => {
266266
let config = new Config(Parse.applicationId);
267267
let object = new Parse.Object('AnObject');
@@ -278,14 +278,14 @@ describe('Pointer Permissions', () => {
278278
done();
279279
})
280280
});
281-
281+
282282
it('tests CLP / Pointer Perms / ACL write (PP Locked)', (done) => {
283283
/*
284284
tests:
285285
CLP: update open ({"*": true})
286286
PointerPerm: "owner"
287287
ACL: logged in user has access
288-
288+
289289
The owner is another user than the ACL
290290
*/
291291
let config = new Config(Parse.applicationId);
@@ -325,7 +325,7 @@ describe('Pointer Permissions', () => {
325325
done();
326326
});
327327
});
328-
328+
329329
it('tests CLP / Pointer Perms / ACL write (ACL Locked)', (done) => {
330330
/*
331331
tests:
@@ -370,7 +370,7 @@ describe('Pointer Permissions', () => {
370370
done();
371371
});
372372
});
373-
373+
374374
it('tests CLP / Pointer Perms / ACL write (ACL/PP OK)', (done) => {
375375
/*
376376
tests:
@@ -415,7 +415,7 @@ describe('Pointer Permissions', () => {
415415
done();
416416
});
417417
});
418-
418+
419419
it('tests CLP / Pointer Perms / ACL read (PP locked)', (done) => {
420420
/*
421421
tests:
@@ -462,7 +462,7 @@ describe('Pointer Permissions', () => {
462462
done();
463463
});
464464
});
465-
465+
466466
it('tests CLP / Pointer Perms / ACL read (PP/ACL OK)', (done) => {
467467
/*
468468
tests:
@@ -509,7 +509,7 @@ describe('Pointer Permissions', () => {
509509
done();
510510
});
511511
});
512-
512+
513513
it('tests CLP / Pointer Perms / ACL read (ACL locked)', (done) => {
514514
/*
515515
tests:
@@ -554,7 +554,7 @@ describe('Pointer Permissions', () => {
554554
done();
555555
});
556556
});
557-
557+
558558
it('should let master key find objects', (done) => {
559559
let config = new Config(Parse.applicationId);
560560
let user = new Parse.User();
@@ -569,7 +569,7 @@ describe('Pointer Permissions', () => {
569569
let q = new Parse.Query('AnObject');
570570
return q.find();
571571
}).then(() => {
572-
572+
573573
}, (err) => {
574574
expect(err.code).toBe(101);
575575
return Promise.resolve();
@@ -584,7 +584,7 @@ describe('Pointer Permissions', () => {
584584
done();
585585
})
586586
});
587-
587+
588588
it('should let master key get objects', (done) => {
589589
let config = new Config(Parse.applicationId);
590590
let user = new Parse.User();
@@ -599,7 +599,7 @@ describe('Pointer Permissions', () => {
599599
let q = new Parse.Query('AnObject');
600600
return q.get(object.id);
601601
}).then(() => {
602-
602+
603603
}, (err) => {
604604
expect(err.code).toBe(101);
605605
return Promise.resolve();
@@ -615,8 +615,8 @@ describe('Pointer Permissions', () => {
615615
done();
616616
})
617617
});
618-
619-
618+
619+
620620
it('should let master key update objects', (done) => {
621621
let config = new Config(Parse.applicationId);
622622
let user = new Parse.User();
@@ -630,7 +630,7 @@ describe('Pointer Permissions', () => {
630630
}).then(() => {
631631
return object.save({'hello': 'bar'});
632632
}).then(() => {
633-
633+
634634
}, (err) => {
635635
expect(err.code).toBe(101);
636636
return Promise.resolve();
@@ -644,7 +644,7 @@ describe('Pointer Permissions', () => {
644644
done();
645645
})
646646
});
647-
647+
648648
it('should let master key delete objects', (done) => {
649649
let config = new Config(Parse.applicationId);
650650
let user = new Parse.User();
@@ -658,7 +658,7 @@ describe('Pointer Permissions', () => {
658658
}).then(() => {
659659
return object.destroy();
660660
}).then(() => {
661-
661+
fail();
662662
}, (err) => {
663663
expect(err.code).toBe(101);
664664
return Promise.resolve();
@@ -671,7 +671,7 @@ describe('Pointer Permissions', () => {
671671
done();
672672
})
673673
});
674-
674+
675675
it('should fail with invalid pointer perms', () => {
676676
let config = new Config(Parse.applicationId);
677677
config.database.loadSchema().then((schema) => {
@@ -682,7 +682,7 @@ describe('Pointer Permissions', () => {
682682
done();
683683
});
684684
});
685-
685+
686686
it('should fail with invalid pointer perms', () => {
687687
let config = new Config(Parse.applicationId);
688688
config.database.loadSchema().then((schema) => {
@@ -693,5 +693,5 @@ describe('Pointer Permissions', () => {
693693
done();
694694
});
695695
})
696-
696+
697697
});

0 commit comments

Comments
 (0)