jsonapi-authorization icon indicating copy to clipboard operation
jsonapi-authorization copied to clipboard

Testing polymorphic has_many associations

Open valscion opened this issue 5 years ago • 4 comments

Since jsonapi-resources v0.9.6 it has been possible to do updates to polymorphic has_many associations: https://github.com/cerebris/jsonapi-resources/pull/1217

We should probably have some sort of a test to verify jsonapi-authorization works for these cases.

Would be nice if this new test case was written in a way where all the code needed for the test would be next to the test file itself, as described in https://github.com/venuu/jsonapi-authorization/pull/124#issuecomment-477892117

valscion avatar Mar 29 '19 08:03 valscion

0.9.6 seems use {type: 'some-type', ids: [...]} as params to identify polymorphic has_many associations, which can't be simply passed to ActiveRecord's find function. This behavior breaks the polymorphic has_many association authorization.

ouabing avatar Apr 16 '19 08:04 ouabing

@ouabing can you show an example scenario where there's breakage? Preferably open a new issue with that information :relaxed:

valscion avatar Apr 16 '19 10:04 valscion

Oh sorry, finally I found that's my fault. I marked a non-polymorphic relationship as a polymorphic one (which works without problem in JA 1.0 version).

ouabing avatar Apr 17 '19 09:04 ouabing

Thanks for clarifying :relaxed:. I hid the comments above as resolved as this discussion wasn't about the original issue description

valscion avatar Apr 17 '19 11:04 valscion