Skip to content

Commit

Permalink
Add test to ensure you can set ACL in beforeSave (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBrock authored and drew-gross committed May 14, 2016
1 parent e4998c2 commit 1854928
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,34 @@ describe('miscellaneous', function() {
});
});

it('test beforeSave set object acl success', function(done) {
var acl = new Parse.ACL({
'*': { read: true, write: false }
});
Parse.Cloud.beforeSave('BeforeSaveAddACL', function(req, res) {
req.object.setACL(acl);
res.success();
});

var obj = new Parse.Object('BeforeSaveAddACL');
obj.set('lol', true);
obj.save().then(function() {
Parse.Cloud._removeHook('Triggers', 'beforeSave', 'BeforeSaveAddACL');
var query = new Parse.Query('BeforeSaveAddACL');
query.get(obj.id).then(function(objAgain) {
expect(objAgain.get('lol')).toBeTruthy();
expect(objAgain.getACL().equals(acl));
done();
}, function(error) {
fail(error);
done();
});
}, function(error) {
fail(error);
done();
});
});

it('test beforeSave returns value on create and update', (done) => {
var obj = new Parse.Object('BeforeSaveChanged');
obj.set('foo', 'bing');
Expand Down

0 comments on commit 1854928

Please sign in to comment.