beauby / jsonapi

[DEPRECATED] Ruby gem for parsing/rendering JSON API documents.
41 stars 17 forks source link

I think there's an incorrect assertion in `Document#parse_resource_identifier!` #46

Closed diminish7 closed 8 years ago

diminish7 commented 8 years ago

This assertion here: https://github.com/beauby/jsonapi/blob/master/parser/lib/jsonapi/parser/document.rb#L126

That assertion currently fails when the resource identifier has both id and type. Based on what the error message is, I think it should test for equality rather than inequality:

ensure!(ri.keys & RESOURCE_IDENTIFIER_KEYS == RESOURCE_IDENTIFIER_KEYS,
                'A resource identifier object MUST contain ' \
                "#{RESOURCE_IDENTIFIER_KEYS} members.")
beauby commented 8 years ago

You are right indeed. I initially expressed all the negated conditions and that one creeped through the change. Would you mind issuing a PR for fixing that? If not, I'll do it over the weekend. Thanks for reporting it!

diminish7 commented 8 years ago

Yep, will do! (Probably tomorrow-ish)

diminish7 commented 8 years ago

@beauby PR'd (#48) Thanks!

beauby commented 8 years ago

Thanks a lot @diminish7 – will review it tonight!