samvera / hydra-role-management

User roles for hydra users
Other
6 stars 11 forks source link

Use user.id instead of user in the path for the "Remove User" delete … #32

Closed coblej closed 6 years ago

coblej commented 6 years ago

…action; addresses #21.

As currently coded, the path for the "Remove User" delete method does not use the ID of the user who is to removed from the role but rather what I presume is the user's user_key, which, if it has the form of an email address, is converted to something of an "escaped" version ... e.g., "user_a@institution-dot-edu". When the code tries to find the user (cf. https://github.com/samvera/hydra-role-management/blob/master/app/controllers/concerns/hydra/role_management/user_roles_behavior.rb#L24 ) in performing the deletion, it is unable to and an ActiveRecord::RecordNotFound error is thrown:

ActiveRecord::RecordNotFound (Couldn't find User with 'id'=user_@institution-dot-edu)

This PR fixes this problem by utilizing the work-around noted by @awead in https://github.com/samvera/hydra-role-management/issues/21#issuecomment-146911788 by which the path for the delete method is formulated using the id of the user; e.g., http://localhost:3000/roles/3/users/1.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 98.66% when pulling 6c79cd1c391361bcd6812aaeeb87adc114db68ee on coblej:21-remove-user-from-role-problem into 1c389c78664d5c814043157c0ecc0d7fdf404eee on samvera:master.