Skip to content
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 customizable permit matcher description #806

Conversation

gregfletch
Copy link

Updates #760 by addressing feedback provided on the original PR.

Closes #759

@Burgestrand
Copy link
Member

Hi again Greg! I'm finally back home now ☺️

This looks good! I realise we lack documentation of the proc-variation of the description, but that can be adjusted later so I'll merge this right away 🙂

@Burgestrand Burgestrand merged commit 0ab259e into varvet:main May 13, 2024
14 checks passed
Burgestrand added a commit that referenced this pull request Aug 26, 2024
## 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
```
@Burgestrand Burgestrand mentioned this pull request Aug 26, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable custom description for permit matcher
4 participants