-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add promise support to built-in model RoleMapping #3169
Add promise support to built-in model RoleMapping #3169
Conversation
Can one of the admins verify this patch? |
3 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
this.applicationModel = reg.getModelByType(loopback.Application); | ||
this.roleModel = reg.getModelByType('Role'); | ||
this.userModel = reg.getModelByType('User'); | ||
this.applicationModel = reg.getModelByType('Application'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is required as the use of loopback.Role
would lead to inconsistent results given the recent introduction of app-local registry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
336abd7
to
d53f05c
Compare
@superkhau, @bajtos i add more promise support as required by #2971 |
@slnode ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two nitpicks, I'll address them myself and force-push to your feature branch.
test/role-mapping.test.js
Outdated
|
||
it('supports .user() with a callback', function(done) { | ||
models.RoleMapping.create( | ||
{principalType: 'USER', principalId: oneUser.id}, function(err, mapping) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one arg per line please - http://loopback.io/doc/en/contrib/style-guide.html#one-argument-per-line
test/role-mapping.test.js
Outdated
|
||
it('supports .childRole() with a callback', function(done) { | ||
models.RoleMapping.create( | ||
{principalType: 'ROLE', principalId: aRole.id}, function(err, mapping) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d53f05c
to
ceceb44
Compare
Landed, thank you! |
Description
None of the methods from built-in model RoleMapping currently support promises. this PR adds promise support by using loopback utils helper
In addition no tests exist for RoleMapping model. this PR also add a new set of tests in a dedicated file to cover both callback and promise versions of those methods
Related issues
related issue: #418
Checklist
guide