mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
roles -> role, null -> COMMENTER for user roles
This commit is contained in:
@@ -33,18 +33,17 @@ const {expect} = chai;
|
||||
`;
|
||||
|
||||
[
|
||||
{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'} ${name} a username with the user roles ${roles && roles.length ? roles : JSON.stringify(roles)}${self ? ' on themself' : ''}`, 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'} ${name} a username with the user role ${role}${self ? ' on themself' : ''}`, 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.
|
||||
|
||||
Reference in New Issue
Block a user