Skip to content

Commit fe3a1bc

Browse files
authored
Merge branch 'alpha' into fix/parse-community#2098
2 parents e0c322a + ab237a2 commit fe3a1bc

File tree

7 files changed

+83
-9
lines changed

7 files changed

+83
-9
lines changed

changelogs/CHANGELOG_alpha.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# [5.1.0-alpha.1](https://github.com/parse-community/Parse-SDK-JS/compare/5.0.0...5.1.0-alpha.1) (2024-03-31)
2+
3+
4+
### Features
5+
6+
* Add password validation for user with unverified email via `Parse.User.verifyPassword` using master key and option `ignoreEmailVerification: true` ([#2076](https://github.com/parse-community/Parse-SDK-JS/issues/2076)) ([b0adf7e](https://github.com/parse-community/Parse-SDK-JS/commit/b0adf7e02ab0beea2cd9b759d0f788c69d291491))
7+
* Add support for setting `Parse.ACL` from json ([#2097](https://github.com/parse-community/Parse-SDK-JS/issues/2097)) ([72bc9ac](https://github.com/parse-community/Parse-SDK-JS/commit/72bc9ac3bfb23443a03742fe47a3b1b2713f8c96))
8+
19
# [5.0.0-alpha.4](https://github.com/parse-community/Parse-SDK-JS/compare/5.0.0-alpha.3...5.0.0-alpha.4) (2024-03-23)
210

311

integration/test/ParseACLTest.js

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ describe('Parse.ACL', () => {
2727
assert(o);
2828
});
2929

30+
it('can set ACL from json', async () => {
31+
Parse.User.enableUnsafeCurrentUser();
32+
const user = new Parse.User();
33+
const object = new TestObject();
34+
user.set('username', 'torn');
35+
user.set('password', 'acl');
36+
await user.signUp();
37+
const acl = new Parse.ACL(user);
38+
object.setACL(acl);
39+
const json = object.toJSON();
40+
await object.save(json);
41+
assert.equal(acl.equals(object.getACL()), true);
42+
});
43+
3044
it('disables public get access', async () => {
3145
const user = new Parse.User();
3246
const object = new TestObject();

integration/test/ParseEventuallyQueueTest.js

+43
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,49 @@ describe('Parse EventuallyQueue', () => {
220220
assert.strictEqual(results.length, 1);
221221
});
222222

223+
it('can saveEventually on object with ACL', async () => {
224+
Parse.User.enableUnsafeCurrentUser();
225+
const parseServer = await reconfigureServer();
226+
const user = new Parse.User();
227+
user.set('username', 'torn');
228+
user.set('password', 'acl');
229+
await user.signUp();
230+
231+
const acl = new Parse.ACL(user);
232+
const object = new TestObject({ hash: 'saveSecret' });
233+
object.setACL(acl);
234+
235+
await new Promise((resolve) => parseServer.server.close(resolve));
236+
237+
await object.saveEventually();
238+
239+
let length = await Parse.EventuallyQueue.length();
240+
assert(Parse.EventuallyQueue.isPolling());
241+
assert.strictEqual(length, 1);
242+
243+
await reconfigureServer({});
244+
245+
while (Parse.EventuallyQueue.isPolling()) {
246+
await sleep(100);
247+
}
248+
assert.strictEqual(Parse.EventuallyQueue.isPolling(), false);
249+
250+
length = await Parse.EventuallyQueue.length();
251+
while (length) {
252+
await sleep(100);
253+
}
254+
length = await Parse.EventuallyQueue.length();
255+
assert.strictEqual(length, 0);
256+
257+
const query = new Parse.Query('TestObject');
258+
query.equalTo('hash', 'saveSecret');
259+
let results = await query.find();
260+
while (results.length === 0) {
261+
results = await query.find();
262+
}
263+
assert.strictEqual(results.length, 1);
264+
});
265+
223266
it('can destroyEventually', async () => {
224267
const parseServer = await reconfigureServer();
225268
const object = new TestObject({ hash: 'deleteSecret' });

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse",
3-
"version": "5.0.0-alpha.4",
3+
"version": "5.1.0-alpha.1",
44
"description": "Parse JavaScript SDK",
55
"homepage": "https://parseplatform.org",
66
"keywords": [

src/ParseObject.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1308,15 +1308,17 @@ class ParseObject {
13081308
options = arg3;
13091309
}
13101310

1311+
options = options || {};
13111312
if (attrs) {
1312-
const validation = this.validate(attrs);
1313-
if (validation) {
1314-
return Promise.reject(validation);
1313+
let validationError;
1314+
options.error = (_, validation) => {
1315+
validationError = validation;
1316+
};
1317+
const success = this.set(attrs, options);
1318+
if (!success) {
1319+
return Promise.reject(validationError);
13151320
}
1316-
this.set(attrs, options);
13171321
}
1318-
1319-
options = options || {};
13201322
const saveOptions = {};
13211323
if (options.hasOwnProperty('useMasterKey')) {
13221324
saveOptions.useMasterKey = !!options.useMasterKey;

src/__tests__/ParseObject-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,13 @@ describe('ParseObject', () => {
365365
expect(o.getACL()).toEqual(ACL);
366366
});
367367

368+
it('encodes ACL from json', () => {
369+
const ACL = new ParseACL({ user1: { read: true } });
370+
const o = new ParseObject('Item');
371+
o.set({ ACL: ACL.toJSON() });
372+
expect(o.getACL()).toEqual(ACL);
373+
});
374+
368375
it('can be rendered to JSON', () => {
369376
let o = new ParseObject('Item');
370377
o.set({

0 commit comments

Comments
 (0)