pundit 2.1.0 → 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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +20 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +26 -0
- data/.github/PULL_REQUEST_TEMPLATE/gem_release_template.md +8 -0
- data/.github/pull_request_template.md +9 -0
- data/.github/workflows/main.yml +147 -0
- data/.github/workflows/push_gem.yml +33 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -29
- data/.rubocop_ignore_git.yml +7 -0
- data/.yardopts +1 -1
- data/CHANGELOG.md +120 -21
- data/CODE_OF_CONDUCT.md +1 -1
- data/CONTRIBUTING.md +3 -5
- data/Gemfile +23 -2
- data/README.md +175 -78
- data/Rakefile +1 -0
- data/SECURITY.md +19 -0
- data/config/rubocop-rspec.yml +5 -0
- data/lib/generators/pundit/install/install_generator.rb +6 -2
- data/lib/generators/pundit/install/templates/{application_policy.rb → application_policy.rb.tt} +7 -3
- data/lib/generators/pundit/policy/policy_generator.rb +6 -2
- data/lib/generators/pundit/policy/templates/policy.rb.tt +16 -0
- data/lib/generators/rspec/policy_generator.rb +7 -2
- data/lib/generators/rspec/templates/{policy_spec.rb → policy_spec.rb.tt} +1 -1
- data/lib/generators/test_unit/policy_generator.rb +7 -2
- data/lib/pundit/authorization.rb +251 -0
- data/lib/pundit/cache_store/legacy_store.rb +24 -0
- data/lib/pundit/cache_store/null_store.rb +27 -0
- data/lib/pundit/cache_store.rb +22 -0
- data/lib/pundit/context.rb +177 -0
- data/lib/pundit/policy_finder.rb +24 -3
- data/lib/pundit/railtie.rb +19 -0
- data/lib/pundit/rspec.rb +93 -20
- data/lib/pundit/version.rb +2 -1
- data/lib/pundit.rb +68 -257
- data/pundit.gemspec +10 -10
- data/spec/authorization_spec.rb +331 -0
- data/spec/generators_spec.rb +43 -0
- data/spec/policies/post_policy_spec.rb +28 -1
- data/spec/policy_finder_spec.rb +84 -17
- data/spec/pundit/helper_spec.rb +18 -0
- data/spec/pundit_spec.rb +110 -233
- data/spec/rspec_dsl_spec.rb +81 -0
- data/spec/simple_cov_check_action_formatter.rb +79 -0
- data/spec/spec_helper.rb +29 -265
- data/spec/support/lib/controller.rb +38 -0
- data/spec/support/lib/custom_cache.rb +19 -0
- data/spec/support/lib/instance_tracking.rb +20 -0
- data/spec/support/models/article.rb +4 -0
- data/spec/support/models/article_tag.rb +7 -0
- data/spec/support/models/artificial_blog.rb +7 -0
- data/spec/support/models/blog.rb +4 -0
- data/spec/support/models/comment.rb +5 -0
- data/spec/support/models/comment_four_five_six.rb +5 -0
- data/spec/support/models/comment_scope.rb +13 -0
- data/spec/support/models/comments_relation.rb +15 -0
- data/spec/support/models/customer/post.rb +11 -0
- data/spec/support/models/default_scope_contains_error.rb +5 -0
- data/spec/support/models/dummy_current_user.rb +7 -0
- data/spec/support/models/foo.rb +4 -0
- data/spec/support/models/post.rb +25 -0
- data/spec/support/models/post_four_five_six.rb +9 -0
- data/spec/support/models/project_one_two_three/avatar_four_five_six.rb +7 -0
- data/spec/support/models/project_one_two_three/tag_four_five_six.rb +11 -0
- data/spec/support/models/wiki.rb +4 -0
- data/spec/support/policies/article_tag_other_name_policy.rb +13 -0
- data/spec/support/policies/base_policy.rb +23 -0
- data/spec/support/policies/blog_policy.rb +5 -0
- data/spec/support/policies/comment_policy.rb +11 -0
- data/spec/support/policies/criteria_policy.rb +5 -0
- data/spec/support/policies/default_scope_contains_error_policy.rb +10 -0
- data/spec/support/policies/denier_policy.rb +7 -0
- data/spec/support/policies/dummy_current_user_policy.rb +9 -0
- data/spec/support/policies/nil_class_policy.rb +17 -0
- data/spec/support/policies/post_policy.rb +36 -0
- data/spec/support/policies/project/admin/comment_policy.rb +15 -0
- data/spec/support/policies/project/comment_policy.rb +17 -0
- data/spec/support/policies/project/criteria_policy.rb +7 -0
- data/spec/support/policies/project/post_policy.rb +13 -0
- data/spec/support/policies/project_one_two_three/avatar_four_five_six_policy.rb +6 -0
- data/spec/support/policies/project_one_two_three/comment_four_five_six_policy.rb +6 -0
- data/spec/support/policies/project_one_two_three/criteria_four_five_six_policy.rb +6 -0
- data/spec/support/policies/project_one_two_three/post_four_five_six_policy.rb +6 -0
- data/spec/support/policies/project_one_two_three/tag_four_five_six_policy.rb +6 -0
- data/spec/support/policies/publication_policy.rb +13 -0
- data/spec/support/policies/wiki_policy.rb +8 -0
- metadata +80 -130
- data/.travis.yml +0 -21
- data/lib/generators/pundit/policy/templates/policy.rb +0 -9
- /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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e34d4263a4c386c0078ddfed804532e292357926fefb505b62bcea9c6e3d08d
|
4
|
+
data.tar.gz: 67c3471d5354cba97b650185770f81bdcc79699f8cbc4d8e60c99b57639a6cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
## To do
|
2
|
+
|
3
|
+
- [ ] Make changes:
|
4
|
+
- [ ] Bump `Pundit::VERSION` in `lib/pundit/version.rb`.
|
5
|
+
- [ ] Update `CHANGELOG.md`.
|
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)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
## To do
|
2
|
+
|
3
|
+
- [ ] I have read the [contributing guidelines](https://github.com/varvet/pundit/contribute).
|
4
|
+
- [ ] I have added relevant tests.
|
5
|
+
- [ ] I have adjusted relevant documentation.
|
6
|
+
- [ ] I have made sure the individual commits are meaningful.
|
7
|
+
- [ ] I have added relevant lines to the CHANGELOG.
|
8
|
+
|
9
|
+
PS: Thank you for contributing to Pundit ❤️
|
@@ -0,0 +1,147 @@
|
|
1
|
+
name: Main
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: ["main"]
|
6
|
+
pull_request:
|
7
|
+
workflow_dispatch:
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
env:
|
13
|
+
CC_TEST_REPORTER_ID: "ac477089fe20ab4fc7e0d304cab75f72d73d58a7596d366935d18fcc7d51f8f9"
|
14
|
+
|
15
|
+
# `github.ref` points to the *merge commit* when running tests on a pull request, which will be a commit
|
16
|
+
# that doesn't exists in our code base. Since this workflow triggers from a PR, we use the HEAD SHA instead.
|
17
|
+
#
|
18
|
+
# NOTE: These are both used by Code Climate (cc-test-reporter).
|
19
|
+
GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
|
20
|
+
GIT_BRANCH: ${{ github.head_ref }}
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
matrix-test:
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
continue-on-error: ${{ matrix.allow-failure || false }}
|
26
|
+
strategy:
|
27
|
+
fail-fast: false
|
28
|
+
matrix:
|
29
|
+
ruby-version:
|
30
|
+
- "3.1"
|
31
|
+
- "3.2"
|
32
|
+
- "3.3"
|
33
|
+
- "jruby-9.3.15"
|
34
|
+
- "jruby"
|
35
|
+
include: # HEAD-versions
|
36
|
+
- ruby-version: "head"
|
37
|
+
allow-failure: true
|
38
|
+
- ruby-version: "jruby-head"
|
39
|
+
allow-failure: true
|
40
|
+
- ruby-version: "truffleruby-head"
|
41
|
+
allow-failure: true
|
42
|
+
|
43
|
+
steps:
|
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
|
53
|
+
|
54
|
+
test:
|
55
|
+
runs-on: ubuntu-latest
|
56
|
+
steps:
|
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
|
106
|
+
|
107
|
+
rubocop:
|
108
|
+
runs-on: ubuntu-latest
|
109
|
+
steps:
|
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
|
133
|
+
|
134
|
+
required-checks:
|
135
|
+
runs-on: ubuntu-latest
|
136
|
+
if: ${{ always() }}
|
137
|
+
needs:
|
138
|
+
- test
|
139
|
+
- matrix-test
|
140
|
+
- docs
|
141
|
+
- rubocop
|
142
|
+
steps:
|
143
|
+
- name: failure
|
144
|
+
if: ${{ failure() || contains(needs.*.result, 'failure') }}
|
145
|
+
run: exit 1
|
146
|
+
- name: success
|
147
|
+
run: exit 0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Push Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
permissions:
|
7
|
+
contents: read
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
push:
|
11
|
+
if: github.repository == 'varvet/pundit'
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
permissions:
|
15
|
+
contents: write
|
16
|
+
id-token: write
|
17
|
+
|
18
|
+
steps:
|
19
|
+
# Set up
|
20
|
+
- name: Harden Runner
|
21
|
+
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
|
22
|
+
with:
|
23
|
+
egress-policy: audit
|
24
|
+
|
25
|
+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
26
|
+
- name: Set up Ruby
|
27
|
+
uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
|
28
|
+
with:
|
29
|
+
bundler-cache: true
|
30
|
+
ruby-version: ruby
|
31
|
+
|
32
|
+
# Release
|
33
|
+
- uses: rubygems/release-gem@612653d273a73bdae1df8453e090060bb4db5f31 # v1+ unreleased
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
+
inherit_from: .rubocop_ignore_git.yml
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
TargetRubyVersion: 3.1
|
5
|
+
SuggestExtensions: false
|
6
|
+
NewCops: disable
|
7
|
+
|
8
|
+
Gemspec/DeprecatedAttributeAssignment:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Gemspec/DevelopmentDependencies:
|
12
|
+
Enabled: true
|
8
13
|
|
9
14
|
Metrics/BlockLength:
|
10
15
|
Exclude:
|
11
16
|
- "**/*_spec.rb"
|
17
|
+
- pundit.gemspec
|
12
18
|
|
13
19
|
Metrics/MethodLength:
|
14
20
|
Max: 40
|
@@ -18,19 +24,13 @@ Metrics/ModuleLength:
|
|
18
24
|
Exclude:
|
19
25
|
- "**/*_spec.rb"
|
20
26
|
|
21
|
-
|
27
|
+
Layout/LineLength:
|
22
28
|
Max: 120
|
23
29
|
|
24
|
-
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Metrics/CyclomaticComplexity:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
Metrics/PerceivedComplexity:
|
30
|
+
Gemspec/RequiredRubyVersion:
|
31
31
|
Enabled: false
|
32
32
|
|
33
|
-
Layout/
|
33
|
+
Layout/ParameterAlignment:
|
34
34
|
EnforcedStyle: with_fixed_indentation
|
35
35
|
|
36
36
|
Layout/CaseIndentation:
|
@@ -40,19 +40,19 @@ Layout/CaseIndentation:
|
|
40
40
|
- end
|
41
41
|
IndentOneStep: true
|
42
42
|
|
43
|
-
Layout/
|
44
|
-
EnforcedStyle:
|
43
|
+
Layout/FirstArrayElementIndentation:
|
44
|
+
EnforcedStyle: consistent
|
45
|
+
|
46
|
+
Layout/FirstHashElementIndentation:
|
47
|
+
EnforcedStyle: consistent
|
45
48
|
|
46
49
|
Layout/EndAlignment:
|
47
50
|
EnforcedStyleAlignWith: variable
|
48
51
|
|
49
|
-
Style/FrozenStringLiteralComment:
|
50
|
-
Enabled: true
|
51
|
-
|
52
52
|
Style/PercentLiteralDelimiters:
|
53
53
|
PreferredDelimiters:
|
54
|
-
|
55
|
-
|
54
|
+
"%w": "[]"
|
55
|
+
"%W": "[]"
|
56
56
|
|
57
57
|
Style/StringLiterals:
|
58
58
|
EnforcedStyle: double_quotes
|
@@ -63,14 +63,11 @@ Style/StringLiteralsInInterpolation:
|
|
63
63
|
Style/StructInheritance:
|
64
64
|
Enabled: false
|
65
65
|
|
66
|
-
Style/AndOr:
|
67
|
-
Enabled: false
|
68
|
-
|
69
|
-
Style/Not:
|
70
|
-
Enabled: false
|
71
|
-
|
72
66
|
Style/DoubleNegation:
|
73
67
|
Enabled: false
|
74
68
|
|
75
|
-
Documentation:
|
69
|
+
Style/Documentation:
|
76
70
|
Enabled: false # TODO: Enable again once we have more docs
|
71
|
+
|
72
|
+
Style/HashSyntax:
|
73
|
+
EnforcedShorthandSyntax: never
|
@@ -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
|
-
--
|
1
|
+
--no-private --private --protected --hide-void-return --markup markdown --fail-on-warning
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,111 @@
|
|
1
1
|
# Pundit
|
2
2
|
|
3
|
+
## Unreleased
|
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
|
+
|
36
|
+
## 2.3.2 (2024-05-08)
|
37
|
+
|
38
|
+
- Refactor: First pass of Pundit::Context [#797](https://github.com/varvet/pundit/issues/797)
|
39
|
+
|
40
|
+
### Changed
|
41
|
+
|
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)
|
44
|
+
|
45
|
+
## Deprecated
|
46
|
+
|
47
|
+
- Dropped support for Ruby 3.0 [#796](https://github.com/varvet/pundit/issues/796)
|
48
|
+
|
49
|
+
## 2.3.1 (2023-07-17)
|
50
|
+
|
51
|
+
### Fixed
|
52
|
+
|
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)
|
55
|
+
|
56
|
+
## 2.3.0 (2022-12-19)
|
57
|
+
|
58
|
+
### Added
|
59
|
+
|
60
|
+
- add support for rubocop-rspec syntax extensions [#745](https://github.com/varvet/pundit/issues/745)
|
61
|
+
|
62
|
+
## 2.2.0 (2022-02-11)
|
63
|
+
|
64
|
+
### Fixed
|
65
|
+
|
66
|
+
- Using `policy_class` and a namespaced record now passes only the record when instantiating the policy. (#697, #689, #694, #666)
|
67
|
+
|
68
|
+
### Changed
|
69
|
+
|
70
|
+
- Require users to explicitly define Scope#resolve in generated policies (#711, #722)
|
71
|
+
|
72
|
+
### Deprecated
|
73
|
+
|
74
|
+
- Deprecate `include Pundit` in favor of `include Pundit::Authorization` [#621](https://github.com/varvet/pundit/issues/621)
|
75
|
+
|
76
|
+
## 2.1.1 (2021-08-13)
|
77
|
+
|
78
|
+
Friday 13th-release!
|
79
|
+
|
80
|
+
Careful! The bugfix below [#626](https://github.com/varvet/pundit/issues/626) could break existing code. If you rely on the
|
81
|
+
return value for `authorize` and namespaced policies you might need to do some
|
82
|
+
changes.
|
83
|
+
|
84
|
+
### Fixed
|
85
|
+
|
86
|
+
- `.authorize` and `#authorize` return the instance, even for namespaced
|
87
|
+
policies [#626](https://github.com/varvet/pundit/issues/626)
|
88
|
+
|
89
|
+
### Changed
|
90
|
+
|
91
|
+
- Generate application scope with `protected` attr_readers. [#616](https://github.com/varvet/pundit/issues/616)
|
92
|
+
|
93
|
+
### Removed
|
94
|
+
|
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)
|
99
|
+
|
100
|
+
## 2.1.0 (2019-08-14)
|
101
|
+
|
3
102
|
### Fixed
|
4
103
|
|
5
|
-
- Avoid name clashes with the Error class.
|
104
|
+
- Avoid name clashes with the Error class. [#590](https://github.com/varvet/pundit/issues/590)
|
6
105
|
|
7
106
|
### Changed
|
8
107
|
|
9
|
-
- Return a safer default NotAuthorizedError message.
|
108
|
+
- Return a safer default NotAuthorizedError message. [#583](https://github.com/varvet/pundit/issues/583)
|
10
109
|
|
11
110
|
## 2.0.1 (2019-01-18)
|
12
111
|
|
@@ -16,8 +115,8 @@ None
|
|
16
115
|
|
17
116
|
### Other changes
|
18
117
|
|
19
|
-
- Improve exception handling for `#policy_scope` and `#policy_scope!`.
|
20
|
-
- Add `:policy` metadata to RSpec template.
|
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)
|
21
120
|
|
22
121
|
## 2.0.0 (2018-07-21)
|
23
122
|
|
@@ -27,20 +126,20 @@ No changes since beta1
|
|
27
126
|
|
28
127
|
### Breaking changes
|
29
128
|
|
30
|
-
- Only pass last element of "namespace array" to policy and scope.
|
31
|
-
- Raise `InvalidConstructorError` if a policy or policy scope with an invalid constructor is called.
|
32
|
-
- Return passed object from `#authorize` method to make chaining possible.
|
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)
|
33
132
|
|
34
133
|
### Other changes
|
35
134
|
|
36
|
-
- Add `policy_class` option to `authorize` to be able to override the policy.
|
37
|
-
- Add `policy_scope_class` option to `authorize` to be able to override the policy scope.
|
38
|
-
- Fix `param_key` issue when passed an array.
|
39
|
-
- Allow specification of a `NilClassPolicy`.
|
40
|
-
- Make sure `policy_class` override is called when passed an array.
|
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)
|
41
140
|
|
42
|
-
- Use `action_name` instead of `params[:action]`.
|
43
|
-
- Add `pundit_params_for` method to make it easy to customize params fetching.
|
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)
|
44
143
|
|
45
144
|
## 1.1.0 (2016-01-14)
|
46
145
|
|
@@ -72,16 +171,16 @@ No changes since beta1
|
|
72
171
|
|
73
172
|
## 0.3.0 (2014-08-22)
|
74
173
|
|
75
|
-
- Extend the default `ApplicationPolicy` with an `ApplicationPolicy::Scope`
|
76
|
-
- Fix RSpec 3 deprecation warnings for built-in matchers
|
77
|
-
- Generate blank policy spec/test files for Rspec/MiniTest/Test::Unit in Rails
|
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)
|
78
177
|
|
79
178
|
## 0.2.3 (2014-04-06)
|
80
179
|
|
81
|
-
- Customizable error messages: `#query`, `#record` and `#policy` methods on `Pundit::NotAuthorizedError`
|
82
|
-
- Raise a different `Pundit::AuthorizationNotPerformedError` when `authorize` call is expected in controller action but missing
|
83
|
-
- Update Rspec matchers for Rspec 3
|
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)
|
84
183
|
|
85
184
|
## 0.2.2 (2014-02-07)
|
86
185
|
|
87
|
-
- Customize the user to be passed into policies: `pundit_user`
|
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
|
-
[
|
28
|
+
[https://contributor-covenant.org/version/1/0/0/](https://contributor-covenant.org/version/1/0/0/)
|
data/CONTRIBUTING.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
## Security issues
|
2
2
|
|
3
|
-
If you have found a security related issue, please do not file an issue on
|
4
|
-
GitHub or send a PR addressing the issue. Contact
|
5
|
-
[Jonas](mailto:jonas.nicklas@gmail.com) directly. You will be given public
|
6
|
-
credit for your disclosure.
|
3
|
+
If you have found a security related issue, please do not file an issue on GitHub or send a PR addressing the issue. Refer to [SECURITY.md](./SECURITY.md) for instructions.
|
7
4
|
|
8
5
|
## Reporting issues
|
9
6
|
|
@@ -23,7 +20,7 @@ Pundit version, OS version and any stack traces you have are very valuable.
|
|
23
20
|
- **Document any change in behaviour**. Make sure the README and any other
|
24
21
|
relevant documentation are kept up-to-date.
|
25
22
|
|
26
|
-
- **Create topic branches**. Please don't ask us to pull from your
|
23
|
+
- **Create topic branches**. Please don't ask us to pull from your main branch.
|
27
24
|
|
28
25
|
- **One pull request per feature**. If you want to do more than one thing, send
|
29
26
|
multiple pull requests.
|
@@ -31,3 +28,4 @@ Pundit version, OS version and any stack traces you have are very valuable.
|
|
31
28
|
- **Send coherent history**. Make sure each individual commit in your pull
|
32
29
|
request is meaningful. If you had to make multiple intermediate commits while
|
33
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
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
ruby RUBY_VERSION
|
6
|
-
|
7
5
|
gemspec
|
6
|
+
|
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"
|