Skip to content

Commit

Permalink
fix: Promise is not being returned in classUpdate method (parse-commu…
Browse files Browse the repository at this point in the history
…nity#5877)

* fix: Set falsy values as default to schema fields

* fix: Promise is not being returned in classUpdate method
  • Loading branch information
alencarlucas authored and dplewis committed Aug 1, 2019
1 parent 8eed8af commit 7e2b2dd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,42 @@ describe('SchemaController', () => {
});
});

it('can update class level permission', done => {
const newLevelPermissions = {
find: {},
get: { '*': true },
count: {},
create: { '*': true },
update: {},
delete: { '*': true },
addField: {},
protectedFields: { '*': [] },
};
config.database.loadSchema().then(schema => {
schema
.validateObject('NewClass', { foo: 2 })
.then(() => schema.reloadData())
.then(() =>
schema.updateClass(
'NewClass',
{},
newLevelPermissions,
{},
config.database
)
)
.then(actualSchema => {
expect(dd(actualSchema.classLevelPermissions, newLevelPermissions)).toEqual(undefined);
done();
})
.catch(error => {
console.trace(error);
done();
fail('Error creating class: ' + JSON.stringify(error));
});
});
});

it('will fail to create a class if that class was already created by an object', done => {
config.database.loadSchema().then(schema => {
schema
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/SchemaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ export default class SchemaController {
})
.then(results => {
enforceFields = results.filter(result => !!result);
this.setPermissions(className, classLevelPermissions, newSchema);
return this.setPermissions(className, classLevelPermissions, newSchema);
})
.then(() =>
this._dbAdapter.setIndexesWithSchemaFormat(
Expand Down

0 comments on commit 7e2b2dd

Please sign in to comment.