Skip to content

Commit

Permalink
Account: id, { roles:[] }
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Oct 10, 2012
1 parent af94764 commit a04e23d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions entitlement.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ var RootAccount = {
"toString" : function() { return this.id + ': ' + Object.keys(this.roles).join(','); }
};

function Account(id,roles)
function Account(id,options)
{
var rs = {};

for(var i in roles) {
var e = roles[i];
for(var i in options.roles) {
var e = options.roles[i];
rs[e] = _roles[e];
if(!rs[e]) rs[e] = Role(e);
}
Expand Down Expand Up @@ -89,6 +89,10 @@ exports.registerAccounts = function(accounts)
}
}

exports.accountHasEntitlement = function(account,entitlement)
{
return true;
}

exports.Entitlement = Entitlement;
exports.Role = Role;
Expand Down
4 changes: 2 additions & 2 deletions tests/entitlement.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ vows.describe('entitlement').addBatch({
}
},
'declare account': {
topic: Account('acc1',['role1']),
topic: Account('acc1',{roles:['role1','role2']}),
'id present': function(account) {
assert.equal(account.id, 'acc1');
},
'toString': function(entitlement) {
assert.equal(entitlement.toString(), 'acc1: role1');
assert.equal(entitlement.toString(), 'acc1: role1,role2');
}
}
}).export(module);
Expand Down

0 comments on commit a04e23d

Please sign in to comment.