Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Add support for non-default models #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zero5100
Copy link
Contributor

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

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
@ritch
Copy link
Contributor

ritch commented Jun 26, 2015

Could you post an example? I'm pretty sure we can land this.

@zero5100
Copy link
Contributor Author

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");

@zero5100
Copy link
Contributor Author

Please let me know when you are ready to merge this so I can fix the merge conflicts.

@beeman
Copy link

beeman commented Aug 13, 2015

+1

@STRML
Copy link

STRML commented Sep 21, 2015

Could this please be merged? I'm seeing broken tests across the board mostly because of the user/User capitalization issue, and the broken use of .constructor.login.

roleMappingModelName + ' not found');
}

RoleMapping.create(
{principalId: test.user.id,
Copy link

Choose a reason for hiding this comment

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

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}, ..)

Copy link

Choose a reason for hiding this comment

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

@zero5100 I would also suggest to add more tests to test the new and impacted existing methods.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

6 participants