Skip to content
Browse files

Fix bug adding a previous existing application (bug was when adding r…

…oles).

Added applications test.
  • Loading branch information...
1 parent b66af77 commit 3465aae07a5754deb485b55ff286c502ad664792 @dresende committed
Showing with 22 additions and 2 deletions.
  1. +2 −2 lib/roles.js
  2. +20 −0 test/applications.js
View
4 lib/roles.js
@@ -250,7 +250,7 @@ function addApplication(name, roles) {
if (app === null) {
applications[name] = new Application(name, roles);
} else if (roles && roles.length) {
- applications[name].addRoles(roles);
+ applications[name].addRoles.apply(applications[name], roles);
}
if (!module.exports.hasOwnProperty(name)) {
@@ -265,7 +265,7 @@ function addProfile(name, roles) {
if (profile === null) {
profiles[name] = new Profile(name, roles);
} else if (roles && roles.length) {
- profiles[name].addRoles(roles);
+ profiles[name].addRoles.apply(profiles[name], roles);
}
if (!module.exports.hasOwnProperty(name)) {
View
20 test/applications.js
@@ -0,0 +1,20 @@
+var roles = require("./../lib/roles"),
+ vows = require("vows"),
+ assert = require("assert");
+
+roles.addApplication("testapp", [ "read", "write" ]);
+
+vows.describe("application").addBatch({
+ "The test application": {
+ topic: roles.testapp,
+ "has 2 roles": function (topic) {
+ assert.lengthOf(topic.roles, 2);
+ },
+ "has role 'read'": function (topic) {
+ assert.equal(topic.roles[0], "read");
+ },
+ "has role 'write'": function (topic) {
+ assert.equal(topic.roles[1], "write");
+ }
+ }
+}).export(module);

0 comments on commit 3465aae

Please sign in to comment.
Something went wrong with that request. Please try again.