Skip to content

Commit

Permalink
Release v2.4.0
Browse files Browse the repository at this point in the history
## 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
```
  • Loading branch information
Burgestrand committed Aug 26, 2024
1 parent 6eaaca6 commit 6eaf877
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

## Unreleased

## 2.4.0 (2024-08-26)

## Changed

- Improve the `NotAuthorizedError` message to include the policy class.
Furthermore, in the case where the record passed is a class instead of an instance, the class name is given. (#812)
Furthermore, in the case where the record passed is a class instead of an instance, the class name is given. (#812)

## Added

- Add customizable permit matcher description (#806)
- Add support for filter_run_when_matching :focus with permissions helper. (#820)

Expand Down
2 changes: 1 addition & 1 deletion lib/pundit/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Pundit
VERSION = "2.3.2"
VERSION = "2.4.0"
end

0 comments on commit 6eaf877

Please sign in to comment.