pundit 2.3.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +26 -0
  4. data/.github/PULL_REQUEST_TEMPLATE/gem_release_template.md +4 -4
  5. data/.github/workflows/main.yml +92 -52
  6. data/.github/workflows/push_gem.yml +4 -4
  7. data/.rubocop.yml +18 -8
  8. data/.rubocop_ignore_git.yml +7 -0
  9. data/.yardopts +1 -1
  10. data/CHANGELOG.md +68 -37
  11. data/CODE_OF_CONDUCT.md +1 -1
  12. data/CONTRIBUTING.md +1 -0
  13. data/Gemfile +22 -2
  14. data/README.md +88 -15
  15. data/Rakefile +1 -0
  16. data/lib/generators/pundit/install/install_generator.rb +3 -1
  17. data/lib/generators/pundit/policy/policy_generator.rb +3 -1
  18. data/lib/generators/rspec/policy_generator.rb +4 -1
  19. data/lib/generators/test_unit/policy_generator.rb +4 -1
  20. data/lib/pundit/authorization.rb +152 -77
  21. data/lib/pundit/cache_store/legacy_store.rb +7 -0
  22. data/lib/pundit/cache_store/null_store.rb +9 -0
  23. data/lib/pundit/cache_store.rb +22 -0
  24. data/lib/pundit/context.rb +76 -26
  25. data/lib/pundit/policy_finder.rb +22 -1
  26. data/lib/pundit/railtie.rb +19 -0
  27. data/lib/pundit/rspec.rb +90 -7
  28. data/lib/pundit/version.rb +2 -1
  29. data/lib/pundit.rb +43 -15
  30. data/pundit.gemspec +8 -12
  31. data/spec/authorization_spec.rb +61 -4
  32. data/spec/policies/post_policy_spec.rb +27 -0
  33. data/spec/policy_finder_spec.rb +5 -1
  34. data/spec/pundit/helper_spec.rb +18 -0
  35. data/spec/pundit_spec.rb +58 -15
  36. data/spec/rspec_dsl_spec.rb +81 -0
  37. data/spec/simple_cov_check_action_formatter.rb +79 -0
  38. data/spec/spec_helper.rb +22 -339
  39. data/spec/support/lib/controller.rb +38 -0
  40. data/spec/support/lib/custom_cache.rb +19 -0
  41. data/spec/support/lib/instance_tracking.rb +20 -0
  42. data/spec/support/models/article.rb +4 -0
  43. data/spec/support/models/article_tag.rb +7 -0
  44. data/spec/support/models/artificial_blog.rb +7 -0
  45. data/spec/support/models/blog.rb +4 -0
  46. data/spec/support/models/comment.rb +5 -0
  47. data/spec/support/models/comment_four_five_six.rb +5 -0
  48. data/spec/support/models/comment_scope.rb +13 -0
  49. data/spec/support/models/comments_relation.rb +15 -0
  50. data/spec/support/models/customer/post.rb +11 -0
  51. data/spec/support/models/default_scope_contains_error.rb +5 -0
  52. data/spec/support/models/dummy_current_user.rb +7 -0
  53. data/spec/support/models/foo.rb +4 -0
  54. data/spec/support/models/post.rb +25 -0
  55. data/spec/support/models/post_four_five_six.rb +9 -0
  56. data/spec/support/models/project_one_two_three/avatar_four_five_six.rb +7 -0
  57. data/spec/support/models/project_one_two_three/tag_four_five_six.rb +11 -0
  58. data/spec/support/models/wiki.rb +4 -0
  59. data/spec/support/policies/article_tag_other_name_policy.rb +13 -0
  60. data/spec/support/policies/base_policy.rb +23 -0
  61. data/spec/support/policies/blog_policy.rb +5 -0
  62. data/spec/support/policies/comment_policy.rb +11 -0
  63. data/spec/support/policies/criteria_policy.rb +5 -0
  64. data/spec/support/policies/default_scope_contains_error_policy.rb +10 -0
  65. data/spec/support/policies/denier_policy.rb +7 -0
  66. data/spec/support/policies/dummy_current_user_policy.rb +9 -0
  67. data/spec/support/policies/nil_class_policy.rb +17 -0
  68. data/spec/support/policies/post_policy.rb +36 -0
  69. data/spec/support/policies/project/admin/comment_policy.rb +15 -0
  70. data/spec/support/policies/project/comment_policy.rb +17 -0
  71. data/spec/support/policies/project/criteria_policy.rb +7 -0
  72. data/spec/support/policies/project/post_policy.rb +13 -0
  73. data/spec/support/policies/project_one_two_three/avatar_four_five_six_policy.rb +6 -0
  74. data/spec/support/policies/project_one_two_three/comment_four_five_six_policy.rb +6 -0
  75. data/spec/support/policies/project_one_two_three/criteria_four_five_six_policy.rb +6 -0
  76. data/spec/support/policies/project_one_two_three/post_four_five_six_policy.rb +6 -0
  77. data/spec/support/policies/project_one_two_three/tag_four_five_six_policy.rb +6 -0
  78. data/spec/support/policies/publication_policy.rb +13 -0
  79. data/spec/support/policies/wiki_policy.rb +8 -0
  80. metadata +66 -158
  81. /data/.github/{PULL_REQUEST_TEMPLATE/pull_request_template.md → pull_request_template.md} +0 -0
  82. /data/lib/generators/pundit/install/templates/{application_policy.rb → application_policy.rb.tt} +0 -0
  83. /data/lib/generators/pundit/policy/templates/{policy.rb → policy.rb.tt} +0 -0
  84. /data/lib/generators/rspec/templates/{policy_spec.rb → policy_spec.rb.tt} +0 -0
  85. /data/lib/generators/test_unit/templates/{policy_test.rb → policy_test.rb.tt} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa554bffd828649aeac4e79a802070d4e68948beacbc9c991fddab7141a965c9
4
- data.tar.gz: edf9be8366e5dfcb541eff929e99a04c2bfb23b800214bc39d68c790b32d7365
3
+ metadata.gz: 2e34d4263a4c386c0078ddfed804532e292357926fefb505b62bcea9c6e3d08d
4
+ data.tar.gz: 67c3471d5354cba97b650185770f81bdcc79699f8cbc4d8e60c99b57639a6cee
5
5
  SHA512:
6
- metadata.gz: 555ccc09f0cc62c3e1da52a7eafb2c3e4805a303c884da39c2ed1c8fc13583727d3e060381ed761f5dd06fdcc71cc3f98c4c991e64db8ac3ff5ff5a460f64aac
7
- data.tar.gz: be290f6d6253367e0911525969fc8bb8972db670626bd9803ccd6e7fc1a1504afd1c921a5aac506ee9cfe559a9863bfb469dca3a656909b7ffa1d74aa4c6ea36
6
+ metadata.gz: e67f07116623c8fd505ed254a165136be512ea36f7635ca2e6062fd59bf73a23eb1a4bf5790a390ff6b4e014e3baf0f7f8e7b649e6e50a8985fcff2e6c27cecd
7
+ data.tar.gz: 65f7d1132b00f9bdcb8b717e08c402a5f6a9a90de5fa07e017b831cbb3ac7b9c11f8869466e3112fea4acddd1699dc495fe30b3234fab06c213ea65dd459c1fd
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a bug report to report a problem
4
+ title: ''
5
+ labels: problem
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps or runnable code to reproduce the problem.
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **Additional context**
20
+ Add any other context about the problem here.
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea
4
+ title: ''
5
+ labels: ['feature request']
6
+ assignees: ''
7
+ ---
8
+
9
+ **Please consider**
10
+ - Could this feature break backwards-compatibility?
11
+ - Could this feature benefit the many who use Pundit?
12
+ - Could this feature be useful in _most_ projects that use Pundit?
13
+ - Would this feature require Rails?
14
+ - Am I open to creating a Pull Request with the necessary changes?
15
+
16
+ **Is your feature request related to a problem? Please describe.**
17
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
18
+
19
+ **Describe the solution you'd like**
20
+ A clear and concise description of how you'd like to approach solving the problem.
21
+
22
+ **Describe alternatives you've considered**
23
+ A clear and concise description of any alternative solutions or features you've considered.
24
+
25
+ **Additional context**
26
+ Add any other context. Ex. if you've solved this problem in your own projects already, how that worked, and why the feature should be moved and maintained in Pundit instead.
@@ -1,8 +1,8 @@
1
1
  ## To do
2
2
 
3
- - [ ] Commit changes:
3
+ - [ ] Make changes:
4
4
  - [ ] Bump `Pundit::VERSION` in `lib/pundit/version.rb`.
5
5
  - [ ] Update `CHANGELOG.md`.
6
- - [ ] Run `rake release`.
7
- - [ ] Open pull request 🚀
8
- - [ ] Make an announcement in [Pundit discussions](https://github.com/varvet/pundit/discussions/categories/announcements).
6
+ - [ ] Open pull request 🚀 and merge it.
7
+ - [ ] Run [push gem](https://github.com/varvet/pundit/actions/workflows/push_gem.yml) GitHub Action.
8
+ - [ ] Make an announcement in [Pundit discussions](https://github.com/varvet/pundit/discussions/categories/announcements)
@@ -2,9 +2,8 @@ name: Main
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ "main" ]
5
+ branches: ["main"]
6
6
  pull_request:
7
- branches: [ "main" ]
8
7
  workflow_dispatch:
9
8
 
10
9
  permissions:
@@ -28,69 +27,109 @@ jobs:
28
27
  fail-fast: false
29
28
  matrix:
30
29
  ruby-version:
31
- - '3.1'
32
- - '3.2'
33
- - '3.3'
34
- - 'jruby-9.3.10' # oldest supported jruby
35
- - 'jruby'
30
+ - "3.1"
31
+ - "3.2"
32
+ - "3.3"
33
+ - "jruby-9.3.15"
34
+ - "jruby"
36
35
  include: # HEAD-versions
37
- - ruby-version: 'head'
36
+ - ruby-version: "head"
38
37
  allow-failure: true
39
- - ruby-version: 'jruby-head'
38
+ - ruby-version: "jruby-head"
40
39
  allow-failure: true
41
- - ruby-version: 'truffleruby-head'
40
+ - ruby-version: "truffleruby-head"
42
41
  allow-failure: true
43
42
 
44
43
  steps:
45
- - uses: actions/checkout@v3
46
- - name: Set up Ruby
47
- uses: ruby/setup-ruby@v1
48
- with:
49
- rubygems: latest
50
- ruby-version: ${{ matrix.ruby-version }}
51
- bundler-cache: true
52
- - name: Run tests
53
- run: bundle exec rspec
44
+ - uses: actions/checkout@v4
45
+ - name: Set up Ruby
46
+ uses: ruby/setup-ruby@v1
47
+ with:
48
+ rubygems: latest
49
+ ruby-version: ${{ matrix.ruby-version }}
50
+ bundler-cache: true
51
+ - name: Run tests
52
+ run: bundle exec rspec
54
53
 
55
54
  test:
56
55
  runs-on: ubuntu-latest
57
56
  steps:
58
- - uses: actions/checkout@v3
59
- - name: Set up Ruby
60
- uses: ruby/setup-ruby@v1
61
- with:
62
- rubygems: latest
63
- ruby-version: 'ruby'
64
- bundler-cache: true
65
- - name: "Download cc-test-reporter from codeclimate.com"
66
- run: |
67
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
68
- chmod +x ./cc-test-reporter
69
- - name: "Report to Code Climate that we will send a coverage report."
70
- run: ./cc-test-reporter before-build
71
- - name: Run tests
72
- run: bundle exec rspec
73
- env:
74
- COVERAGE: 1
75
- - name: Upload code coverage to Code Climate
76
- run: |
77
- ./cc-test-reporter after-build \
78
- --coverage-input-type simplecov \
79
- ./coverage/.resultset.json
57
+ - uses: actions/checkout@v4
58
+ - name: Set up Ruby
59
+ uses: ruby/setup-ruby@v1
60
+ with:
61
+ rubygems: latest
62
+ ruby-version: "ruby"
63
+ bundler-cache: true
64
+ - name: "Download cc-test-reporter from codeclimate.com"
65
+ run: |
66
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
67
+ chmod +x ./cc-test-reporter
68
+ - name: "Report to Code Climate that we will send a coverage report."
69
+ run: ./cc-test-reporter before-build
70
+ - name: Run tests
71
+ run: bundle exec rspec
72
+ env:
73
+ COVERAGE: 1
74
+ - name: Upload coverage results
75
+ uses: actions/upload-artifact@v4
76
+ with:
77
+ include-hidden-files: true
78
+ name: coverage-results
79
+ path: coverage
80
+ retention-days: 1
81
+ - name: Upload code coverage to Code Climate
82
+ run: |
83
+ ./cc-test-reporter after-build \
84
+ --coverage-input-type simplecov \
85
+ ./coverage/.resultset.json
86
+
87
+ coverage-check:
88
+ permissions:
89
+ contents: read
90
+ checks: write
91
+ needs: test
92
+ runs-on: ubuntu-latest
93
+ steps:
94
+ - uses: actions/checkout@v4
95
+ - name: Download coverage results
96
+ uses: actions/download-artifact@v4
97
+ with:
98
+ name: coverage-results
99
+ path: coverage
100
+ - uses: joshmfrankel/simplecov-check-action@be89e11889202cc59efb14aab2a7091622fa9aad
101
+ with:
102
+ github_token: ${{ secrets.GITHUB_TOKEN }}
103
+ minimum_suite_coverage: 100
104
+ minimum_file_coverage: 100
105
+ coverage_json_path: coverage/simplecov-check-action.json
80
106
 
81
107
  rubocop:
82
108
  runs-on: ubuntu-latest
83
109
  steps:
84
- - uses: actions/checkout@v3
85
- - name: Set up Ruby
86
- uses: ruby/setup-ruby@v1
87
- with:
88
- rubygems: default
89
- ruby-version: 'ruby'
90
- bundler-cache: false
91
- - run: bundle install
92
- - name: Run RuboCop
93
- run: bundle exec rubocop
110
+ - uses: actions/checkout@v4
111
+ - name: Set up Ruby
112
+ uses: ruby/setup-ruby@v1
113
+ with:
114
+ rubygems: default
115
+ ruby-version: "ruby"
116
+ bundler-cache: false
117
+ - run: bundle install
118
+ - name: Run RuboCop
119
+ run: bundle exec rubocop
120
+
121
+ docs:
122
+ runs-on: ubuntu-latest
123
+ steps:
124
+ - uses: actions/checkout@v4
125
+ - name: Set up Ruby
126
+ uses: ruby/setup-ruby@v1
127
+ with:
128
+ rubygems: default
129
+ ruby-version: "ruby"
130
+ bundler-cache: false
131
+ - run: bundle install
132
+ - run: rake yard
94
133
 
95
134
  required-checks:
96
135
  runs-on: ubuntu-latest
@@ -98,10 +137,11 @@ jobs:
98
137
  needs:
99
138
  - test
100
139
  - matrix-test
140
+ - docs
101
141
  - rubocop
102
142
  steps:
103
143
  - name: failure
104
144
  if: ${{ failure() || contains(needs.*.result, 'failure') }}
105
145
  run: exit 1
106
146
  - name: success
107
- run: exit 0
147
+ run: exit 0
@@ -18,16 +18,16 @@ jobs:
18
18
  steps:
19
19
  # Set up
20
20
  - name: Harden Runner
21
- uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
21
+ uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
22
22
  with:
23
23
  egress-policy: audit
24
24
 
25
- - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
25
+ - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
26
26
  - name: Set up Ruby
27
- uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0
27
+ uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
28
28
  with:
29
29
  bundler-cache: true
30
30
  ruby-version: ruby
31
31
 
32
32
  # Release
33
- - uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1
33
+ - uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1+ unreleased
data/.rubocop.yml CHANGED
@@ -1,16 +1,20 @@
1
+ inherit_from: .rubocop_ignore_git.yml
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 3.1
3
- Exclude:
4
- - "lib/generators/**/templates/**/*"
5
- <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
6
- - <%= path.sub(/^!! /, '').sub(/\/$/, '/**/*') %>
7
- <% end %>
8
5
  SuggestExtensions: false
9
6
  NewCops: disable
10
7
 
8
+ Gemspec/DeprecatedAttributeAssignment:
9
+ Enabled: true
10
+
11
+ Gemspec/DevelopmentDependencies:
12
+ Enabled: true
13
+
11
14
  Metrics/BlockLength:
12
15
  Exclude:
13
16
  - "**/*_spec.rb"
17
+ - pundit.gemspec
14
18
 
15
19
  Metrics/MethodLength:
16
20
  Max: 40
@@ -24,7 +28,7 @@ Layout/LineLength:
24
28
  Max: 120
25
29
 
26
30
  Gemspec/RequiredRubyVersion:
27
- Enabled: false
31
+ Enabled: false
28
32
 
29
33
  Layout/ParameterAlignment:
30
34
  EnforcedStyle: with_fixed_indentation
@@ -36,13 +40,19 @@ Layout/CaseIndentation:
36
40
  - end
37
41
  IndentOneStep: true
38
42
 
43
+ Layout/FirstArrayElementIndentation:
44
+ EnforcedStyle: consistent
45
+
46
+ Layout/FirstHashElementIndentation:
47
+ EnforcedStyle: consistent
48
+
39
49
  Layout/EndAlignment:
40
50
  EnforcedStyleAlignWith: variable
41
51
 
42
52
  Style/PercentLiteralDelimiters:
43
53
  PreferredDelimiters:
44
- '%w': "[]"
45
- '%W': "[]"
54
+ "%w": "[]"
55
+ "%W": "[]"
46
56
 
47
57
  Style/StringLiterals:
48
58
  EnforcedStyle: double_quotes
@@ -0,0 +1,7 @@
1
+ # This is here so we can keep YAML syntax highlight in the main file.
2
+ AllCops:
3
+ Exclude:
4
+ - "lib/generators/**/templates/**/*"
5
+ <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
6
+ - <%= path.sub(/^!! /, '').sub(/\/$/, '/**/*') %>
7
+ <% end %>
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --api public --hide-void-return --markup markdown
1
+ --no-private --private --protected --hide-void-return --markup markdown --fail-on-warning
data/CHANGELOG.md CHANGED
@@ -2,31 +2,62 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.5.0 (2025-03-03)
6
+
7
+ ### Added
8
+
9
+ - Add `Pundit::Authorization#pundit_reset!` hook to reset the policy and policy scope cache. [#830](https://github.com/varvet/pundit/issues/830)
10
+ - Add links to gemspec. [#845](https://github.com/varvet/pundit/issues/845)
11
+ - Register policies directories for Rails 8 code statistics [#833](https://github.com/varvet/pundit/issues/833)
12
+ - Added an example for how to use pundit with Rails 8 authentication generator [#850](https://github.com/varvet/pundit/issues/850)
13
+
14
+ ### Changed
15
+
16
+ - Deprecated `Pundit::SUFFIX`, moved it to `Pundit::PolicyFinder::SUFFIX` [#835](https://github.com/varvet/pundit/issues/835)
17
+ - Explicitly require less of `active_support` [#837](https://github.com/varvet/pundit/issues/837)
18
+ - Using `permit` matcher without a surrouding `permissions` block now raises a useful error. [#836](https://github.com/varvet/pundit/issues/836)
19
+
20
+ ### Fixed
21
+
22
+ - Using a hash as custom cache in `Pundit.authorize` now works as documented. [#838](https://github.com/varvet/pundit/issues/838)
23
+
24
+ ## 2.4.0 (2024-08-26)
25
+
26
+ ### Changed
27
+
28
+ - Improve the `NotAuthorizedError` message to include the policy class.
29
+ Furthermore, in the case where the record passed is a class instead of an instance, the class name is given. [#812](https://github.com/varvet/pundit/issues/812)
30
+
31
+ ### Added
32
+
33
+ - Add customizable permit matcher description [#806](https://github.com/varvet/pundit/issues/806)
34
+ - Add support for filter_run_when_matching :focus with permissions helper. [#820](https://github.com/varvet/pundit/issues/820)
35
+
5
36
  ## 2.3.2 (2024-05-08)
6
37
 
7
- - Refactor: First pass of Pundit::Context (#797)
38
+ - Refactor: First pass of Pundit::Context [#797](https://github.com/varvet/pundit/issues/797)
8
39
 
9
- ## Changed
40
+ ### Changed
10
41
 
11
- - Update `ApplicationPolicy` generator to qualify the `Scope` class name (#792)
12
- - Policy generator uses `NoMethodError` to indicate `#resolve` is not implemented (#776)
42
+ - Update `ApplicationPolicy` generator to qualify the `Scope` class name [#792](https://github.com/varvet/pundit/issues/792)
43
+ - Policy generator uses `NoMethodError` to indicate `#resolve` is not implemented [#776](https://github.com/varvet/pundit/issues/776)
13
44
 
14
45
  ## Deprecated
15
46
 
16
- - Dropped support for Ruby 3.0 (#796)
47
+ - Dropped support for Ruby 3.0 [#796](https://github.com/varvet/pundit/issues/796)
17
48
 
18
49
  ## 2.3.1 (2023-07-17)
19
50
 
20
51
  ### Fixed
21
52
 
22
- - Use `Kernel.warn` instead of `ActiveSupport::Deprecation.warn` for deprecations (#764)
23
- - Policy generator now works on Ruby 3.2 (#754)
53
+ - Use `Kernel.warn` instead of `ActiveSupport::Deprecation.warn` for deprecations [#764](https://github.com/varvet/pundit/issues/764)
54
+ - Policy generator now works on Ruby 3.2 [#754](https://github.com/varvet/pundit/issues/754)
24
55
 
25
56
  ## 2.3.0 (2022-12-19)
26
57
 
27
58
  ### Added
28
59
 
29
- - add support for rubocop-rspec syntax extensions (#745)
60
+ - add support for rubocop-rspec syntax extensions [#745](https://github.com/varvet/pundit/issues/745)
30
61
 
31
62
  ## 2.2.0 (2022-02-11)
32
63
 
@@ -40,41 +71,41 @@
40
71
 
41
72
  ### Deprecated
42
73
 
43
- - Deprecate `include Pundit` in favor of `include Pundit::Authorization` (#621)
74
+ - Deprecate `include Pundit` in favor of `include Pundit::Authorization` [#621](https://github.com/varvet/pundit/issues/621)
44
75
 
45
76
  ## 2.1.1 (2021-08-13)
46
77
 
47
78
  Friday 13th-release!
48
79
 
49
- Careful! The bugfix below (#626) could break existing code. If you rely on the
80
+ Careful! The bugfix below [#626](https://github.com/varvet/pundit/issues/626) could break existing code. If you rely on the
50
81
  return value for `authorize` and namespaced policies you might need to do some
51
82
  changes.
52
83
 
53
84
  ### Fixed
54
85
 
55
86
  - `.authorize` and `#authorize` return the instance, even for namespaced
56
- policies (#626)
87
+ policies [#626](https://github.com/varvet/pundit/issues/626)
57
88
 
58
89
  ### Changed
59
90
 
60
- - Generate application scope with `protected` attr_readers. (#616)
91
+ - Generate application scope with `protected` attr_readers. [#616](https://github.com/varvet/pundit/issues/616)
61
92
 
62
93
  ### Removed
63
94
 
64
- - Dropped support for Ruby end-of-life versions: 2.1 and 2.2. (#604)
65
- - Dropped support for Ruby end-of-life versions: 2.3 (#633)
66
- - Dropped support for Ruby end-of-life versions: 2.4, 2.5 and JRuby 9.1 (#676)
67
- - Dropped support for RSpec 2 (#615)
95
+ - Dropped support for Ruby end-of-life versions: 2.1 and 2.2. [#604](https://github.com/varvet/pundit/issues/604)
96
+ - Dropped support for Ruby end-of-life versions: 2.3 [#633](https://github.com/varvet/pundit/issues/633)
97
+ - Dropped support for Ruby end-of-life versions: 2.4, 2.5 and JRuby 9.1 [#676](https://github.com/varvet/pundit/issues/676)
98
+ - Dropped support for RSpec 2 [#615](https://github.com/varvet/pundit/issues/615)
68
99
 
69
100
  ## 2.1.0 (2019-08-14)
70
101
 
71
102
  ### Fixed
72
103
 
73
- - Avoid name clashes with the Error class. (#590)
104
+ - Avoid name clashes with the Error class. [#590](https://github.com/varvet/pundit/issues/590)
74
105
 
75
106
  ### Changed
76
107
 
77
- - Return a safer default NotAuthorizedError message. (#583)
108
+ - Return a safer default NotAuthorizedError message. [#583](https://github.com/varvet/pundit/issues/583)
78
109
 
79
110
  ## 2.0.1 (2019-01-18)
80
111
 
@@ -84,8 +115,8 @@ None
84
115
 
85
116
  ### Other changes
86
117
 
87
- - Improve exception handling for `#policy_scope` and `#policy_scope!`. (#550)
88
- - Add `:policy` metadata to RSpec template. (#566)
118
+ - Improve exception handling for `#policy_scope` and `#policy_scope!`. [#550](https://github.com/varvet/pundit/issues/550)
119
+ - Add `:policy` metadata to RSpec template. [#566](https://github.com/varvet/pundit/issues/566)
89
120
 
90
121
  ## 2.0.0 (2018-07-21)
91
122
 
@@ -95,20 +126,20 @@ No changes since beta1
95
126
 
96
127
  ### Breaking changes
97
128
 
98
- - Only pass last element of "namespace array" to policy and scope. (#529)
99
- - Raise `InvalidConstructorError` if a policy or policy scope with an invalid constructor is called. (#462)
100
- - Return passed object from `#authorize` method to make chaining possible. (#385)
129
+ - Only pass last element of "namespace array" to policy and scope. [#529](https://github.com/varvet/pundit/issues/529)
130
+ - Raise `InvalidConstructorError` if a policy or policy scope with an invalid constructor is called. [#462](https://github.com/varvet/pundit/issues/462)
131
+ - Return passed object from `#authorize` method to make chaining possible. [#385](https://github.com/varvet/pundit/issues/385)
101
132
 
102
133
  ### Other changes
103
134
 
104
- - Add `policy_class` option to `authorize` to be able to override the policy. (#441)
105
- - Add `policy_scope_class` option to `authorize` to be able to override the policy scope. (#441)
106
- - Fix `param_key` issue when passed an array. (#529)
107
- - Allow specification of a `NilClassPolicy`. (#525)
108
- - Make sure `policy_class` override is called when passed an array. (#475)
135
+ - Add `policy_class` option to `authorize` to be able to override the policy. [#441](https://github.com/varvet/pundit/issues/441)
136
+ - Add `policy_scope_class` option to `authorize` to be able to override the policy scope. [#441](https://github.com/varvet/pundit/issues/441)
137
+ - Fix `param_key` issue when passed an array. [#529](https://github.com/varvet/pundit/issues/529)
138
+ - Allow specification of a `NilClassPolicy`. [#525](https://github.com/varvet/pundit/issues/525)
139
+ - Make sure `policy_class` override is called when passed an array. [#475](https://github.com/varvet/pundit/issues/475)
109
140
 
110
- - Use `action_name` instead of `params[:action]`. (#419)
111
- - Add `pundit_params_for` method to make it easy to customize params fetching. (#502)
141
+ - Use `action_name` instead of `params[:action]`. [#419](https://github.com/varvet/pundit/issues/419)
142
+ - Add `pundit_params_for` method to make it easy to customize params fetching. [#502](https://github.com/varvet/pundit/issues/502)
112
143
 
113
144
  ## 1.1.0 (2016-01-14)
114
145
 
@@ -140,16 +171,16 @@ No changes since beta1
140
171
 
141
172
  ## 0.3.0 (2014-08-22)
142
173
 
143
- - Extend the default `ApplicationPolicy` with an `ApplicationPolicy::Scope` (#120)
144
- - Fix RSpec 3 deprecation warnings for built-in matchers (#162)
145
- - Generate blank policy spec/test files for Rspec/MiniTest/Test::Unit in Rails (#138)
174
+ - Extend the default `ApplicationPolicy` with an `ApplicationPolicy::Scope` [#120](https://github.com/varvet/pundit/issues/120)
175
+ - Fix RSpec 3 deprecation warnings for built-in matchers [#162](https://github.com/varvet/pundit/issues/162)
176
+ - Generate blank policy spec/test files for Rspec/MiniTest/Test::Unit in Rails [#138](https://github.com/varvet/pundit/issues/138)
146
177
 
147
178
  ## 0.2.3 (2014-04-06)
148
179
 
149
- - Customizable error messages: `#query`, `#record` and `#policy` methods on `Pundit::NotAuthorizedError` (#114)
150
- - Raise a different `Pundit::AuthorizationNotPerformedError` when `authorize` call is expected in controller action but missing (#109)
151
- - Update Rspec matchers for Rspec 3 (#124)
180
+ - Customizable error messages: `#query`, `#record` and `#policy` methods on `Pundit::NotAuthorizedError` [#114](https://github.com/varvet/pundit/issues/114)
181
+ - Raise a different `Pundit::AuthorizationNotPerformedError` when `authorize` call is expected in controller action but missing [#109](https://github.com/varvet/pundit/issues/109)
182
+ - Update Rspec matchers for Rspec 3 [#124](https://github.com/varvet/pundit/issues/124)
152
183
 
153
184
  ## 0.2.2 (2014-02-07)
154
185
 
155
- - Customize the user to be passed into policies: `pundit_user` (#42)
186
+ - Customize the user to be passed into policies: `pundit_user` [#42](https://github.com/varvet/pundit/issues/42)
data/CODE_OF_CONDUCT.md CHANGED
@@ -25,4 +25,4 @@ maintainers.
25
25
 
26
26
  This Code of Conduct is adapted from the [Contributor
27
27
  Covenant](http:contributor-covenant.org), version 1.0.0, available at
28
- [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
28
+ [https://contributor-covenant.org/version/1/0/0/](https://contributor-covenant.org/version/1/0/0/)
data/CONTRIBUTING.md CHANGED
@@ -28,3 +28,4 @@ Pundit version, OS version and any stack traces you have are very valuable.
28
28
  - **Send coherent history**. Make sure each individual commit in your pull
29
29
  request is meaningful. If you had to make multiple intermediate commits while
30
30
  developing, please squash them before sending them to us.
31
+ - **Update the CHANGELOG.** Don't forget to add your new changes to the CHANGELOG.
data/Gemfile CHANGED
@@ -4,5 +4,25 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- # https://github.com/ruby/psych/issues/655
8
- gem "psych", "!= 5.1.1", platforms: %i[jruby]
7
+ # Rails-related - for testing purposes
8
+ gem "actionpack", ">= 3.0.0" # Used to test strong parameters
9
+ gem "activemodel", ">= 3.0.0" # Used to test ActiveModel::Naming
10
+ gem "railties", ">= 3.0.0" # Used to test generators
11
+
12
+ # Testing
13
+ gem "rspec", ">= 3.0.0"
14
+ gem "simplecov", ">= 0.17.0"
15
+
16
+ # Development tools
17
+ gem "bundler"
18
+ gem "rake"
19
+ gem "rubocop"
20
+ gem "rubocop-performance"
21
+ gem "rubocop-rspec"
22
+ gem "yard"
23
+ gem "zeitwerk"
24
+
25
+ # Affects us on JRuby 9.3.15.
26
+ #
27
+ # @see https://github.com/rails/rails/issues/54260
28
+ gem "logger"