Add support for non-default models#57
Add support for non-default models#57zero5100 wants to merge 1 commit intostrongloop-archive:masterfrom
Conversation
Default functionality has not changed, but the models that the helpers will use can be customized with beforeEach hooks. Default model names are also clarified by adding constant strings to the top of the helper file. - Update support for custom User model - Add support for custom AccessToken, Role, and RoleMapping model - Add check if models exist before referencing them - Use User.login instead of User.constructor.login - Add new and missing helper methods to helper test
|
Could you post an example? I'm pretty sure we can land this. |
|
I just put these up by where I put the withApp call in my test files. They are all optional, and accept a string of the model name you want to use for each type. lt.beforeEach.withApp(app);
lt.beforeEach.withUserModel("user");
lt.beforeEach.withAccessTokenModel("accessToken");
lt.beforeEach.withRoleModel("role");
lt.beforeEach.withRoleMappingModel("roleMapping"); |
|
Please let me know when you are ready to merge this so I can fix the merge conflicts. |
|
+1 |
|
Could this please be merged? I'm seeing broken tests across the board mostly because of the |
There was a problem hiding this comment.
The User model name also needs to be dynamically resolved. So, test.user.id will not resolve. Something like below would work:
var userModelName = test.userModel ? test.userModel : DEFAULT_USER_MODEL;
RoleMapping.create(
{principalId: test[userModelName].id,
principalType: RoleMapping.USER,
roleId: result.id}, ..)There was a problem hiding this comment.
@zero5100 I would also suggest to add more tests to test the new and impacted existing methods.
Default functionality has not changed, but the models
that the helpers will use can be customized with beforeEach
hooks. Default model names are also clarified by adding
constant strings to the top of the helper file.