-
Notifications
You must be signed in to change notification settings - Fork 19
Fix addition and removal of resources to/from relations #19
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
Conversation
94e864e to
ee09e76
Compare
Fix addition and removal of related resources and create system test that cover this functionality.
ee09e76 to
cb20939
Compare
lib/Resource.js
Outdated
| if (!match) return; | ||
|
|
||
| if (relation.meta.many) { | ||
| if (Resource._rawRelationHasMany(relation)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the variable names consistent between functions? We pass it in here as relation and it pops out above as rawRelation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We sure can. I would prefer to rename here though, because we're using relation to refer to both the related resources collection and the relationship metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍
|
👍 looks great, nice job on cleaning up |
|
All tests pass. Nice cleanup! 👍 |
Fix addition and removal of resources to/from relations
Fixes the addition and removal of resources to/from relations.
The JSON:API specification mandates that if a resource is added multiple times to a relationship it should be de-duplicated (as a result the same related resource should never appear more than once in a relationship).
A typo bug is fixed in the removal of resources from relationships which was uncovered by the new system tests.
Peruse the code changes and make sure those look sane and check that the new system tests cover the previously uncovered buggy use cases.
Also note that the assets required for browser testing are now generated on demand and have been removed from the repository and cross-browser tests have been temporarily prevented from breaking the build (as always it will be possible to see in the Saucelabs badge which specific browsers are failing the tests).