Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
codydaig committed Aug 14, 2015
1 parent 9fc6091 commit 1f7bfdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
3 changes: 3 additions & 0 deletions modules/core/client/services/menus.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ angular.module('core').service('Menus', [
if (!!~this.roles.indexOf('*')) {
return true;
} else {
if(!user) {
return false;
}
for (var userRoleIndex in user.roles) {
for (var roleIndex in this.roles) {
if (this.roles[roleIndex] === user.roles[userRoleIndex]) {
Expand Down
17 changes: 5 additions & 12 deletions modules/core/tests/client/menus.client.service.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
expect(Menus.menus.topbar).toBeDefined();
});

it('should have default roles to *', function() {
expect(Menus.defaultRoles).toEqual(['*']);
it('should have default roles to user and admin', function() {
expect(Menus.defaultRoles).toEqual(['user', 'admin']);
});

describe('addMenu', function() {
Expand All @@ -42,7 +42,7 @@
});

it('should set shouldRender to shouldRender function handle', function() {
expect(menu.shouldRender()).toBeTruthy();
expect(menu.shouldRender()).toBeFalsy();
});
});

Expand Down Expand Up @@ -79,13 +79,6 @@
it('should render if menu is public', function() {
expect(menu.shouldRender()).toBeTruthy();
});

// it('should not render if menu is private', function() {
// menu = Menus.addMenu('menu1', {
// isPublic: false
// });
// expect(menu.shouldRender()).toBeFalsy();
// });
});

describe('when logged in', function() {
Expand Down Expand Up @@ -259,8 +252,8 @@
expect(menuItem.isPublic).toBeFalsy();
});

it('should set menu item roles to menu roles', function() {
expect(menuItem.roles).toEqual(menu.roles);
it('should set menu item roles to default roles', function() {
expect(menuItem.roles).toEqual(Menus.defaultRoles);
});

it('should set menu item position to 0', function() {
Expand Down

0 comments on commit 1f7bfdd

Please sign in to comment.