Skip to content
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

Merged
merged 1 commit into from
Feb 1, 2017

Conversation

ebarault
Copy link
Contributor

@ebarault ebarault commented Jan 31, 2017

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

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

@slnode
Copy link

slnode commented Jan 31, 2017

Can one of the admins verify this patch?

3 similar comments
@slnode
Copy link

slnode commented Jan 31, 2017

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Jan 31, 2017

Can one of the admins verify this patch?

@slnode
Copy link

slnode commented Jan 31, 2017

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');
}
Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

@ebarault ebarault force-pushed the feature/promisify-role-mapping branch from 336abd7 to d53f05c Compare January 31, 2017 22:14
@ebarault
Copy link
Contributor Author

@superkhau, @bajtos i add more promise support as required by #2971
could you please review?

@bajtos
Copy link
Member

bajtos commented Feb 1, 2017

@slnode ok to test

@bajtos bajtos self-assigned this Feb 1, 2017
Copy link
Member

@bajtos bajtos left a 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.


it('supports .user() with a callback', function(done) {
models.RoleMapping.create(
{principalType: 'USER', principalId: oneUser.id}, function(err, mapping) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


it('supports .childRole() with a callback', function(done) {
models.RoleMapping.create(
{principalType: 'ROLE', principalId: aRole.id}, function(err, mapping) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bajtos bajtos force-pushed the feature/promisify-role-mapping branch from d53f05c to ceceb44 Compare February 1, 2017 08:51
@bajtos bajtos merged commit 76dd35e into strongloop:master Feb 1, 2017
@bajtos
Copy link
Member

bajtos commented Feb 1, 2017

Landed, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants