-
Notifications
You must be signed in to change notification settings - Fork 633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the policy class to the NotAuthorizedError
message
#812
Conversation
Hi! Thanks for updating the old PR! This does not fix #647, but it does fix #681. I'm not sure why the pull request templates we have didn't get proposed, but please have a look at it: https://github.com/varvet/pundit/blob/main/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md - this PR is missing a changelog entry 🙂 |
I updated the PR to now actually take care of #647 and I updated the I did not get the template when I made the PR via the button in my fork. I did however read |
The jruby failures are unrelated to this change. Something is up with the more recent jruby version on our GitHub CI pipeline. |
Either way I think this should probably be good! I'll most likely merge this soon. Travelling to Baltic Ruby today though 😊 |
Co-authored-by: Kim Burgestrand <kim@burgestrand.se>
Co-authored-by: Kim Burgestrand <kim@burgestrand.se>
I think these changes are indeed better so I added them |
Thank you! |
## Improve `NotAuthorizedError` message to include policy class (#812) Default error message changed from: > not allowed to destroy? this Comment To include the policy class: > not allowed to Project::Admin::CommentPolicy#destroy? this Comment ## Improve `NotAuthorizedError` when record is a class Before: > not allowed to index? this Class After: > not allowed to PostPolicy#index? Post ## Allow customizing rspec matcher description (#806) Before: > PostPolicy > update? and show? > is expected to permit #<User:0x0000000104aefd80> and #<Post:0x0000000104aef8d0 @user=#<User:0x0000000104aefd80>> In `spec_helper.rb`: ```ruby Pundit::RSpec::Matchers.description = ->(user, record) do "permit user with role #{user.role} to access record with ID #{record.id}" end ``` After: > PostPolicy > update? and show? > is expected to permit user with role admin to access record with ID 130 ## Add support for filter_run_when_matching :focus with permissions helper (#820) If your RSpec config has filter_run_when_matching :focus, you may tag the permissions helper like so: ```ruby permissions :show?, :focus do ```
This PR fixes #681 and #647.