roles -> role, null -> COMMENTER for user roles

This commit is contained in:
Wyatt Johnson
2017-11-27 11:53:40 -07:00
parent 9386912b9b
commit 13865ff29e
38 changed files with 206 additions and 199 deletions
+11 -12
View File
@@ -57,18 +57,17 @@ describe('graph.mutations.banUser', () => {
`;
[
{self: true, error: 'NOT_AUTHORIZED', roles: null},
{self: true, error: 'NOT_AUTHORIZED', roles: ['STAFF']},
{self: true, error: 'NOT_AUTHORIZED', roles: []},
{error: 'NOT_AUTHORIZED', roles: null},
{error: 'NOT_AUTHORIZED', roles: ['STAFF']},
{error: 'NOT_AUTHORIZED', roles: []},
{error: false, roles: ['MODERATOR']},
{error: false, roles: ['ADMIN']},
{error: false, roles: ['ADMIN', 'MODERATOR']},
].forEach(({self, error, roles}) => {
it(`${error ? 'can not' : 'can'} ban ${self ? 'themself' : 'another user'} as a user with roles ${roles && roles.length ? roles : JSON.stringify(roles)}`, async () => {
const actor = new UserModel({roles});
{self: true, error: 'NOT_AUTHORIZED', role: 'COMMENTER'},
{self: true, error: 'NOT_AUTHORIZED', role: 'STAFF'},
{self: true, error: 'NOT_AUTHORIZED', role: 'COMMENTER'},
{error: 'NOT_AUTHORIZED', role: 'COMMENTER'},
{error: 'NOT_AUTHORIZED', role: 'STAFF'},
{error: 'NOT_AUTHORIZED', role: 'COMMENTER'},
{error: false, role: 'MODERATOR'},
{error: false, role: 'ADMIN'},
].forEach(({self, error, role}) => {
it(`${error ? 'can not' : 'can'} ban ${self ? 'themself' : 'another user'} as a user with role=${role}`, async () => {
const actor = new UserModel({role});
// If we're testing self assign, set the id of the actor to the user
// we're acting on.