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

Support user subclass before save #28

Merged
merged 3 commits into from
Jul 5, 2016

Conversation

acinader
Copy link
Contributor

@acinader acinader commented Jun 20, 2016

fixes #25

unit test coverage for _User class

PS the third commit 75c99d2 just adds semicolons. was bothering me and i figured out linting....

@@ -112,8 +112,7 @@ function runHook(className, hookType, data) {
object: model,
user: "ParseMockDB doesn't define request.user."
};

return hook(beforeSaveOrBeforeDeleteRequestObject).bind(model)().then((beforeSaveOverrideValue) => {
return hook(beforeSaveOrBeforeDeleteRequestObject).then((beforeSaveOverrideValue) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i wish i understood what the .bind(model)() was supposed to do and if it should be there. but now the unit tests pass.

:( any insight you guys can give me as to what it was supposed to do, ideally in the form of a failing test so i can try to figure it out.....

This was referenced Jun 20, 2016
@acinader acinader force-pushed the support-user-subclass-beforeSave branch 5 times, most recently from 7dadc87 to 6a3414b Compare June 29, 2016 01:05
@acinader
Copy link
Contributor Author

@fatuhoku take a look. I rebased your changes, and i took a look at what you did in handle_request, but when i factored it out, i found that it is exactly the same as what was there before?

I fixed the unit tests, but I now need a unit test that fails, cause this really looks like a noop to me? maybe something was fixed in between and when i rebased it, everything just worked??

@acinader acinader force-pushed the support-user-subclass-beforeSave branch 2 times, most recently from 11ca00f to 9598db4 Compare June 29, 2016 01:11
@acinader
Copy link
Contributor Author

@TylerBrock I think that this can be closed unless you think that the extra unit tests are worth keeping? If so, I'll rebase.

@acinader
Copy link
Contributor Author

@fatuhoku I hope you'll try head again and if there is any functionality that you've got implemented that isn't in head, I'd be glad to work with you to get it worked into head!!!

@TylerBrock
Copy link
Contributor

@fatuhoku agree completely with @acinader thank you for all the hard work. Please continue to contribute.

@acinader what is your opinion on keeping the tests? worth it?

Pass in the request object into the beforeSave handler.

Rename variable.

Rename request.

Add failing test for beforeDelete.

Fix test by switching the flag.

Fail test again by not defining a return value.

Reason about beforeSave override value.

Fix test by performing deletion.

Simplify creation of Brand.

Remove TODO by adding assertion for empty collection.

Add assertions for the state of the mock collection.

Fix semicolons.

Replace => syntax with function() syntax.

Inline variable.

Remove whitespace.
@acinader acinader force-pushed the support-user-subclass-beforeSave branch from 9598db4 to 511c1d7 Compare June 29, 2016 21:53
1. don't use switch
2. get unit tests in working order
3. remove code duplication in unit tests.
@acinader acinader force-pushed the support-user-subclass-beforeSave branch from 511c1d7 to 789a65f Compare June 29, 2016 22:23
@acinader
Copy link
Contributor Author

@TylerBrock probably?

npm test | grep ✓ | awk '{print substr($0, index($0, $3))}' | sort | uniq -c

2 rejects the delete if there is a problem
2 rejects the save if there is a problem
2 runs the hook before deleting the object
2 runs the hook before saving the model and persists the object
....

it's certainly valid that those tests should be run twice, once for a "plain" parse class, and once for the special parse class _User, but the code shouldn't be duplicated. I'll see if can quickly refactor, if so I'll amend this. if not, we should probably merge it anyway :).

@acinader
Copy link
Contributor Author

combined the tests for parse objects and _User using @fatuhoku methods. Nice!

yup, @TylerBrock I'd like you to review it for merge.

I figured out how to set up lint for this stuff using eslint.
@acinader
Copy link
Contributor Author

acinader commented Jul 2, 2016

@TylerBrock nudge

@TylerBrock
Copy link
Contributor

Hey sorry for the delay. I'm out of town this weekend. Most likely I'll review on Tuesday.

@TylerBrock
Copy link
Contributor

I don't think this is mergeable if the deep save test fails. Can we figure out what is going on there?

@acinader
Copy link
Contributor Author

acinader commented Jul 5, 2016

i didn't touch that test https://github.com/HustleInc/parse-mockdb/blob/master/test/test.js#L830

it fails on master too. the only thing i did was change the test from being commented out to marked skip using xit.

which is nice because it shows that the test is skipped when you npm test:

    ✓ should skip and limit items appropriately
    - should deep save and update nested objects
    ✓ successfully uses containsAll query

The test's comment cites an issue that you had opened: parse-community/Parse-SDK-JS#91

the issue was marked resolved in parse sdk in version 1.6.14. I'm running 1.8.5 as our package.json has >=1.6.0

I can open an issue on this repo and look into why it still fails, any background you have might be helpful?

@TylerBrock
Copy link
Contributor

Oh, duh, thank you! Much better! It was too early to be looking at diffs apparently.

Yeah, it would be great to get an issue to track it. Would be happy to fill in info where necessary.

@TylerBrock TylerBrock merged commit 37acae2 into Hustle:master Jul 5, 2016
@TylerBrock
Copy link
Contributor

TylerBrock commented Jul 5, 2016

Two questions:

  • want me to do a release for this change?
  • should we update the readme to reflect the current state of the project's support for parse features?

@acinader
Copy link
Contributor Author

acinader commented Jul 7, 2016

Yeah the readme and some code comments need updating. Will do.

@acinader
Copy link
Contributor Author

no opinion on release.

here's an update for the readme: #41

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

Successfully merging this pull request may close these issues.

Get fatuhoku pr's merged...
2 participants