You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a new method to DefaultPunditAuthorizer for this case. Name the method remove_to_many_relationship and create a similar implementation to remove_to_one_relationship.
This PR is up for grabs!
If you want to implement this, add a comment to this issue saying so!☺️
Setup:
HTTP call:
Current situation:
We will call
Suggestion:
Call a specific method when removing all comments:
Reason for suggestion:
This mirrors the way a removal of has-one relationship is done:
...which ends up calling
because of the check done in
JSONAPI:: Authorization:: AuthorizingProcessor
Implementation suggestion:
Add a new method to
DefaultPunditAuthorizer
for this case. Name the methodremove_to_many_relationship
and create a similar implementation toremove_to_one_relationship
.Create tests for the new authorizer method. You can mirror the
#replace_to_one_relationship
method specs.Add new logic to
AuthorizingProcessor#authorize_replace_to_many_relationships
method to check for the possible emptiness ofparams[:data]
array, and then bail out by calling the newremove_to_one_relationship
method on the authorizer.Add new case to relationship operations request spec to cover this new logic. You can mirror the existing specs of "when nullifying the author" on has-one relationship PATCH. The new spec should be under the
describe 'PATCH /articles/:id/relationships/comments' do
blockUse distinct policy method for clearing out has-many association? #73 (comment)
The text was updated successfully, but these errors were encountered: