Skip to content

Commit

Permalink
Test for making sure userIsInRole returns false for unknown roles.
Browse files Browse the repository at this point in the history
See: #204
  • Loading branch information
mitar committed Oct 2, 2016
1 parent 1e7212a commit c5e27a8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions roles/tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,28 @@
}, /form a cycle/);
});

Tinytest.add(
'roles - userIsInRole returns false for unknown roles',
function (test) {
reset();

Roles.createRole('admin');
Roles.createRole('user');
Roles.createRole('editor');
Roles.addUsersToRoles(users.eve, ['admin', 'user']);
Roles.addUsersToRoles(users.eve, ['editor']);

test.isFalse(Roles.userIsInRole(users.eve, 'unknown'));
test.isFalse(Roles.userIsInRole(users.eve, []));
test.isFalse(Roles.userIsInRole(users.eve, null));
test.isFalse(Roles.userIsInRole(users.eve, undefined));

test.isFalse(Roles.userIsInRole(users.eve, 'unknown', {anyScope: true}));
test.isFalse(Roles.userIsInRole(users.eve, [], {anyScope: true}));
test.isFalse(Roles.userIsInRole(users.eve, null, {anyScope: true}));
test.isFalse(Roles.userIsInRole(users.eve, undefined, {anyScope: true}));
});

function printException (ex) {
var tmp = {};
for (var key in ex) {
Expand Down

0 comments on commit c5e27a8

Please sign in to comment.