pundit 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +16 -6
- data/config/rubocop-rspec.yml +5 -0
- data/lib/pundit/version.rb +1 -1
- data/lib/pundit.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74f2f6efff0c12342afad4bb45dc75f12443e20f6ab5a9ed40274f2f842f2441
|
4
|
+
data.tar.gz: ad984e338045f040964301fdf2c79323d2e1a1ebffad16fc332d49315de14da2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106c8df42fc14b485dc4ea3951fba00232b6fa739b0a5910d9c33a33dde04cb1c015ecbf77f07a38274b9f9ae43ea5cfbbafb283f5eddc42fbf9454820ab87af
|
7
|
+
data.tar.gz: 4ab2a989938496acf224a9b20c247010e8d5882de168a995a02dbde021d308d7602f6305d675b26d461dcfb171346b02a1979325471f8713644aab8aac2dab9a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,8 +24,8 @@ Sponsored by:
|
|
24
24
|
|
25
25
|
> **Please note** that the README on GitHub is accurate with the _latest code on GitHub_. You are most likely using a released version of Pundit, so please refer to the [documentation for the latest released version of Pundit](https://www.rubydoc.info/gems/pundit).
|
26
26
|
|
27
|
-
```
|
28
|
-
|
27
|
+
``` sh
|
28
|
+
bundle add pundit
|
29
29
|
```
|
30
30
|
|
31
31
|
Include `Pundit::Authorization` in your application controller:
|
@@ -512,7 +512,7 @@ class ApplicationController < ActionController::Base
|
|
512
512
|
|
513
513
|
def user_not_authorized
|
514
514
|
flash[:alert] = "You are not authorized to perform this action."
|
515
|
-
|
515
|
+
redirect_back(fallback_location: root_path)
|
516
516
|
end
|
517
517
|
end
|
518
518
|
```
|
@@ -541,7 +541,7 @@ class ApplicationController < ActionController::Base
|
|
541
541
|
policy_name = exception.policy.class.to_s.underscore
|
542
542
|
|
543
543
|
flash[:error] = t "#{policy_name}.#{exception.query}", scope: "pundit", default: :default
|
544
|
-
|
544
|
+
redirect_back(fallback_url: root_path)
|
545
545
|
end
|
546
546
|
end
|
547
547
|
```
|
@@ -692,7 +692,7 @@ You can now retrieve these attributes from the policy:
|
|
692
692
|
class PostsController < ApplicationController
|
693
693
|
def update
|
694
694
|
@post = Post.find(params[:id])
|
695
|
-
if @post.
|
695
|
+
if @post.update(post_params)
|
696
696
|
redirect_to @post
|
697
697
|
else
|
698
698
|
render :edit
|
@@ -714,7 +714,7 @@ However, this is a bit cumbersome, so Pundit provides a convenient helper method
|
|
714
714
|
class PostsController < ApplicationController
|
715
715
|
def update
|
716
716
|
@post = Post.find(params[:id])
|
717
|
-
if @post.
|
717
|
+
if @post.update(permitted_attributes(@post))
|
718
718
|
redirect_to @post
|
719
719
|
else
|
720
720
|
render :edit
|
@@ -802,6 +802,16 @@ An alternative approach to Pundit policy specs is scoping them to a user context
|
|
802
802
|
|
803
803
|
Pundit does not provide a DSL for testing scopes. Just test it like a regular Ruby class!
|
804
804
|
|
805
|
+
### Linting with RuboCop RSpec
|
806
|
+
|
807
|
+
When you lint your RSpec spec files with `rubocop-rspec`, it will fail to properly detect RSpec constructs that Pundit defines, `permissions`.
|
808
|
+
Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`:
|
809
|
+
|
810
|
+
```yaml
|
811
|
+
inherit_gem:
|
812
|
+
pundit: config/rubocop-rspec.yml
|
813
|
+
```
|
814
|
+
|
805
815
|
# External Resources
|
806
816
|
|
807
817
|
- [RailsApps Example Application: Pundit and Devise](https://github.com/RailsApps/rails-devise-pundit)
|
data/lib/pundit/version.rb
CHANGED
data/lib/pundit.rb
CHANGED
@@ -55,7 +55,7 @@ module Pundit
|
|
55
55
|
class NotDefinedError < Error; end
|
56
56
|
|
57
57
|
def self.included(base)
|
58
|
-
ActiveSupport::Deprecation.warn <<~WARNING
|
58
|
+
ActiveSupport::Deprecation.warn <<~WARNING
|
59
59
|
'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead.
|
60
60
|
WARNING
|
61
61
|
base.include Authorization
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pundit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- LICENSE.txt
|
185
185
|
- README.md
|
186
186
|
- Rakefile
|
187
|
+
- config/rubocop-rspec.yml
|
187
188
|
- lib/generators/pundit/install/USAGE
|
188
189
|
- lib/generators/pundit/install/install_generator.rb
|
189
190
|
- lib/generators/pundit/install/templates/application_policy.rb
|
@@ -225,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
226
|
- !ruby/object:Gem::Version
|
226
227
|
version: '0'
|
227
228
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.3.7
|
229
230
|
signing_key:
|
230
231
|
specification_version: 4
|
231
232
|
summary: OO authorization for Rails
|