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

Auth strategy refactor #5963

Merged
merged 2 commits into from Oct 18, 2015
Merged

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Oct 16, 2015

The two commits here can be merged, I've kept them separate to start with to show that I'm not changing behaviour.

The first commit changes the tests from using the DB setup/teardown stuff to not using the DB, as unit tests are not intended to use the DB.

Whilst refactoring the tests, I realised that the slightly more complex .forge().fetch() code can be 1-for-1 replaced with findOne, which just removes a couple of lines of code in both the middleware and the tests, making it all a bit easier to follow, I think.

This PR reduces test coverage, because it prevents the unit tests from executing some of the model layer code that wasn't actually being tested.

- unit tests are not intended to call out to the db
- this fakes the response from the model layer
- Simplifies both strategy & test code
- Should have no side effects
@ErisDS
Copy link
Member Author

ErisDS commented Oct 16, 2015

FYI I found this because I was trying to understand what parts of the crazy code in the model layer are unit tested, and some code that I didn't think got covered appeared as though it was. My next PR should hopefully add some more coverage in key areas that I need to refactor to solve #5604 & particularly #5615

sebgie added a commit that referenced this pull request Oct 18, 2015
@sebgie sebgie merged commit c6b5055 into TryGhost:master Oct 18, 2015
@ErisDS ErisDS deleted the auth-strategy-refactor branch October 18, 2015 15:38
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.

None yet

2 participants