From 178e5dab303d7f76fac4d7a286dd8af67285cb03 Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Tue, 19 Nov 2013 11:02:43 -0800 Subject: [PATCH] Remove .attachTo() from tests --- lib/loopback.js | 4 +++- test/role.test.js | 14 -------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/loopback.js b/lib/loopback.js index f8712ca1..44892820 100644 --- a/lib/loopback.js +++ b/lib/loopback.js @@ -231,7 +231,8 @@ loopback.Email = require('./models/email'); loopback.User = require('./models/user'); loopback.Application = require('./models/application'); loopback.AccessToken = require('./models/access-token'); -loopback.Role = require('./models/role'); +loopback.Role = require('./models/role').Role; +loopback.RoleMapping = require('./models/role').RoleMapping; loopback.ACL = require('./models/acl').ACL; loopback.Scope = require('./models/acl').Scope; @@ -249,6 +250,7 @@ loopback.Email.autoAttach = dataSourceTypes.MAIL; loopback.User.autoAttach = dataSourceTypes.DB; loopback.AccessToken.autoAttach = dataSourceTypes.DB; loopback.Role.autoAttach = dataSourceTypes.DB; +loopback.RoleMapping.autoAttach = dataSourceTypes.DB; loopback.ACL.autoAttach = dataSourceTypes.DB; loopback.Scope.autoAttach = dataSourceTypes.DB; loopback.Application.autoAttach = dataSourceTypes.DB; diff --git a/test/role.test.js b/test/role.test.js index acd561d9..45d7385e 100644 --- a/test/role.test.js +++ b/test/role.test.js @@ -13,10 +13,6 @@ function checkResult(err, result) { describe('role model', function () { it("should define role/role relations", function () { - var ds = loopback.createDataSource({connector: 'memory'}); - Role.attachTo(ds); - RoleMapping.attachTo(ds); - Role.create({name: 'user'}, function (err, userRole) { Role.create({name: 'admin'}, function (err, adminRole) { userRole.principals.create({principalType: RoleMapping.ROLE, principalId: adminRole.id}, function (err, mapping) { @@ -41,11 +37,6 @@ describe('role model', function () { }); it("should define role/user relations", function () { - var ds = loopback.createDataSource({connector: 'memory'}); - User.attachTo(ds); - Role.attachTo(ds); - RoleMapping.attachTo(ds); - User.create({name: 'Raymond', email: 'x@y.com', password: 'foobar'}, function (err, user) { // console.log('User: ', user.id); Role.create({name: 'userRole'}, function (err, role) { @@ -75,11 +66,6 @@ describe('role model', function () { }); it("should support getRoles() and isInRole()", function () { - var ds = loopback.createDataSource({connector: 'memory'}); - User.attachTo(ds); - Role.attachTo(ds); - RoleMapping.attachTo(ds); - User.create({name: 'Raymond', email: 'x@y.com', password: 'foobar'}, function (err, user) { // console.log('User: ', user.id); Role.create({name: 'userRole'}, function (err, role) {