Skip to content

avoid situation where the linkage data could be partially calculated#789

Merged
lgebhardt merged 2 commits intoJSONAPI-Resources:masterfrom
togglepro:no-partial-linkage-data
Aug 31, 2016
Merged

avoid situation where the linkage data could be partially calculated#789
lgebhardt merged 2 commits intoJSONAPI-Resources:masterfrom
togglepro:no-partial-linkage-data

Conversation

@barelyknown
Copy link
Copy Markdown
Collaborator

@barelyknown barelyknown commented Aug 2, 2016

The existing tests pass, though I did not take the time to create a failing test case for the situation (mostly because the easiest way would have been to test the to_one_linkage and to_many_linkage methods directly, and I didn't have time to figure out how to isolate them effectively).

This fixes the situation where the current user does not have permission to access a relationship, and the library was returning a partially complete data object for that relationship when it was polymorphic (the id would be provided, but the type would be an empty string because of the way that Relationship.type_for_source works). To keep it all simple and avoid any side effects, I'm just not returning a partial data object (where either the id or the type are nil) now.

@barelyknown
Copy link
Copy Markdown
Collaborator Author

Hold on with this. Need to manually test a bit more.

@barelyknown
Copy link
Copy Markdown
Collaborator Author

OK, I needed to guard against empty strings too. It should be good now.

@lgebhardt lgebhardt merged commit 2480985 into JSONAPI-Resources:master Aug 31, 2016
@lgebhardt
Copy link
Copy Markdown
Contributor

@barelyknown Thanks!

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.

2 participants