Skip to content

get the related record fails for has_one relationships if the data is not included  #226

Closed
@JohnSmall

Description

@JohnSmall

It's possible for has_one type of relationships not to return the included record, only the id and the type. But the code expects the entire data to be in the 'included' section. If it's not there you get this error

NoMethodError: undefined method `[]' for nil:NilClass
etc/gems/json_api_client-1.3.0/lib/json_api_client/included_data.rb:43:in `record_for'

There are two tests for this, one expecting the included data, and one without the included data, but they both use stubbed JSON that has the included data. So the tests pass although the code doesn't actually work. When I changed the test so that the test for the case where there's no included data uses stubbed JSON that doesn't have included data, as it should do, then the test fails.

I'm trying to fix this, and might make a PR for it, but if it's a known problem and the fix is due out in the next release then I won't bother.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions