From a6d511d8b4073bdb92ce3f70cbb20407a57e04b1 Mon Sep 17 00:00:00 2001 From: Benjamin Kroeger Date: Mon, 16 Jan 2017 15:23:33 +0100 Subject: [PATCH] Role model: resolves related models by name Resolve models related to the `Role` model by name instead of class. --- common/models/role.js | 6 +++--- test/role.test.js | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/common/models/role.js b/common/models/role.js index 05638863..e78dc4ed 100644 --- a/common/models/role.js +++ b/common/models/role.js @@ -24,9 +24,9 @@ module.exports = function(Role) { Role.resolveRelatedModels = function() { if (!this.userModel) { var reg = this.registry; - this.roleMappingModel = reg.getModelByType(loopback.RoleMapping); - this.userModel = reg.getModelByType(loopback.User); - this.applicationModel = reg.getModelByType(loopback.Application); + this.roleMappingModel = reg.getModelByType('RoleMapping'); + this.userModel = reg.getModelByType('User'); + this.applicationModel = reg.getModelByType('Application'); } }; diff --git a/test/role.test.js b/test/role.test.js index d6eccf79..c9390c89 100644 --- a/test/role.test.js +++ b/test/role.test.js @@ -47,9 +47,6 @@ describe('role model', function() { ACL.roleMappingModel = RoleMapping; ACL.userModel = User; ACL.applicationModel = Application; - Role.roleMappingModel = RoleMapping; - Role.userModel = User; - Role.applicationModel = Application; }); it('should define role/role relations', function(done) {