Skip to content

Commit 78c42d9

Browse files
alencarlucasdplewis
authored andcommitted
fix: Promise is not being returned in classUpdate method (#5877)
* fix: Set falsy values as default to schema fields * fix: Promise is not being returned in classUpdate method
1 parent f3b8424 commit 78c42d9

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

spec/Schema.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,42 @@ describe('SchemaController', () => {
426426
});
427427
});
428428

429+
it('can update class level permission', done => {
430+
const newLevelPermissions = {
431+
find: {},
432+
get: { '*': true },
433+
count: {},
434+
create: { '*': true },
435+
update: {},
436+
delete: { '*': true },
437+
addField: {},
438+
protectedFields: { '*': [] },
439+
};
440+
config.database.loadSchema().then(schema => {
441+
schema
442+
.validateObject('NewClass', { foo: 2 })
443+
.then(() => schema.reloadData())
444+
.then(() =>
445+
schema.updateClass(
446+
'NewClass',
447+
{},
448+
newLevelPermissions,
449+
{},
450+
config.database
451+
)
452+
)
453+
.then(actualSchema => {
454+
expect(dd(actualSchema.classLevelPermissions, newLevelPermissions)).toEqual(undefined);
455+
done();
456+
})
457+
.catch(error => {
458+
console.trace(error);
459+
done();
460+
fail('Error creating class: ' + JSON.stringify(error));
461+
});
462+
});
463+
});
464+
429465
it('will fail to create a class if that class was already created by an object', done => {
430466
config.database.loadSchema().then(schema => {
431467
schema

src/Controllers/SchemaController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ export default class SchemaController {
768768
})
769769
.then(results => {
770770
enforceFields = results.filter(result => !!result);
771-
this.setPermissions(className, classLevelPermissions, newSchema);
771+
return this.setPermissions(className, classLevelPermissions, newSchema);
772772
})
773773
.then(() =>
774774
this._dbAdapter.setIndexesWithSchemaFormat(

0 commit comments

Comments
 (0)