Skip to content

Conversation

@pmcnr-hx
Copy link
Contributor

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

  • Me gusta!
  • Yeeeeeep

@pmcnr-hx pmcnr-hx force-pushed the add-related-distinct-resources branch from 94e864e to ee09e76 Compare February 10, 2016 01:09
Fix addition and removal of related resources and create system test
that cover this functionality.
@pmcnr-hx pmcnr-hx force-pushed the add-related-distinct-resources branch from ee09e76 to cb20939 Compare February 10, 2016 01:11
lib/Resource.js Outdated
if (!match) return;

if (relation.meta.many) {
if (Resource._rawRelationHasMany(relation)) {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure 👍

@theninj4
Copy link
Contributor

👍 looks great, nice job on cleaning up /dist too!

@DuncanFenning
Copy link
Contributor

All tests pass. Nice cleanup! 👍

pmcnr-hx added a commit that referenced this pull request Feb 10, 2016
Fix addition and removal of resources to/from relations
@pmcnr-hx pmcnr-hx merged commit 7debff1 into master Feb 10, 2016
@pmcnr-hx pmcnr-hx deleted the add-related-distinct-resources branch February 10, 2016 10:12
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.

4 participants