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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82606dec60dec4ddb9086a4d1a71447bda39f9f17fd5e38025937f0fdb7b9b1a
4
- data.tar.gz: e154a0dadc701871c49687ff843117e590011362be4cf3dfa7bc63ea4e5e698b
3
+ metadata.gz: 74f2f6efff0c12342afad4bb45dc75f12443e20f6ab5a9ed40274f2f842f2441
4
+ data.tar.gz: ad984e338045f040964301fdf2c79323d2e1a1ebffad16fc332d49315de14da2
5
5
  SHA512:
6
- metadata.gz: 0414e7e35eb8e2aa3bac79a75f2d8ae4e45f5cf4152150be239664f620560732990b3547aeac678b50e4b62036ab25c45170f12ca1897c6bf41938589e5ef0bd
7
- data.tar.gz: 964d660d1f79b36b8ace58452ca0adfef4f5ea68a7436f6373ae248f33cda7f017db5d5c5fbd0efca26fb5ee88a507cf900edc8bd0d7dad89a676cb308bd7bd1
6
+ metadata.gz: 106c8df42fc14b485dc4ea3951fba00232b6fa739b0a5910d9c33a33dde04cb1c015ecbf77f07a38274b9f9ae43ea5cfbbafb283f5eddc42fbf9454820ab87af
7
+ data.tar.gz: 4ab2a989938496acf224a9b20c247010e8d5882de168a995a02dbde021d308d7602f6305d675b26d461dcfb171346b02a1979325471f8713644aab8aac2dab9a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Pundit
2
2
 
3
+ ## 2.3.0 (2022-12-19)
4
+
5
+ ### Added
6
+
7
+ - add support for rubocop-rspec syntax extensions (#745)
8
+
3
9
  ## 2.2.0 (2022-02-11)
4
10
 
5
11
  ### Fixed
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
- ``` ruby
28
- gem "pundit"
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
- redirect_to(request.referrer || root_path)
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
- redirect_to(request.referrer || root_path)
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.update_attributes(post_params)
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.update_attributes(permitted_attributes(@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)
@@ -0,0 +1,5 @@
1
+ RSpec:
2
+ Language:
3
+ ExampleGroups:
4
+ Regular:
5
+ - permissions
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pundit
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
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.strip_heredoc
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.2.0
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-02-11 00:00:00.000000000 Z
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.2.32
229
+ rubygems_version: 3.3.7
229
230
  signing_key:
230
231
  specification_version: 4
231
232
  summary: OO authorization for Rails