pundit 2.1.1 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: def6c710d9f9d1705ca43cdad9364bb34ce5d878b8a3a9bf26d336802e40efeb
4
- data.tar.gz: 0d6618cb61dfef8ae18f811a73b3f059d9945f8def7f9b2f794ae095b3a0f0cf
3
+ metadata.gz: 1cc7a931867875af2c1a7cd5c4225da689b33e101f76bb7a471afb967323e615
4
+ data.tar.gz: 8ca35ba01f65b52b1b8bbb2061858bdc61cd0034b01818b07dbbba4b7ddd3a69
5
5
  SHA512:
6
- metadata.gz: 7105cd0a84469071de9211e19f7e7a31f4ea8b5283d7b1ed007b6533805de18d105c09128a9936144612f3daa8fadfdf0698f7448d8db94e47bb459efaa11c4b
7
- data.tar.gz: 3805e2664f21f30c66e9a9a05606f0d0d18b1607137e794948c7907bd33c6d6e64a45b9abb97d2f1a21df0d46497ff708679442807e152fa167abc461c8c0abe
6
+ metadata.gz: 0f495747f61c744c04dffa7811d3a86fc818812807a971591d71542d798d5a7aa4438333534082e755bbead592b4b1b5465e23030e535b03420c643e088bcaf1
7
+ data.tar.gz: 951ec8a8c02c081bc6b412bb0b5d1d6ffcc33543fa71f66fef9c4f4a6f391ea53a057e20b94bdef5faf4c8f2ef0deffd09357c9580ef6a739575c94a70d9d950
@@ -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,112 @@
1
+ name: Main
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ env:
14
+ CC_TEST_REPORTER_ID: "ac477089fe20ab4fc7e0d304cab75f72d73d58a7596d366935d18fcc7d51f8f9"
15
+
16
+ # `github.ref` points to the *merge commit* when running tests on a pull request, which will be a commit
17
+ # that doesn't exists in our code base. Since this workflow triggers from a PR, we use the HEAD SHA instead.
18
+ #
19
+ # NOTE: These are both used by Code Climate (cc-test-reporter).
20
+ GIT_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
21
+ GIT_BRANCH: ${{ github.head_ref }}
22
+
23
+ jobs:
24
+ matrix-test:
25
+ runs-on: ubuntu-latest
26
+ continue-on-error: ${{ matrix.allow-failure || false }}
27
+ strategy:
28
+ fail-fast: false
29
+ matrix:
30
+ ruby-version:
31
+ - '3.1'
32
+ - '3.2'
33
+ - '3.3'
34
+ - 'jruby-9.3.10' # oldest supported jruby
35
+ - 'jruby'
36
+ include: # HEAD-versions
37
+ - ruby-version: 'head'
38
+ allow-failure: true
39
+ - ruby-version: 'jruby-head'
40
+ allow-failure: true
41
+ - ruby-version: 'truffleruby-head'
42
+ allow-failure: true
43
+
44
+ steps:
45
+ - uses: actions/checkout@v4
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: ${{ !startsWith(matrix.ruby-version, 'jruby') }}
52
+ - name: Bundler install (JRuby workaround)
53
+ if: ${{ startsWith(matrix.ruby-version, 'jruby') }}
54
+ run: |
55
+ gem install psych
56
+ bundle install
57
+ - name: Run tests
58
+ run: bundle exec rspec
59
+
60
+ test:
61
+ runs-on: ubuntu-latest
62
+ steps:
63
+ - uses: actions/checkout@v4
64
+ - name: Set up Ruby
65
+ uses: ruby/setup-ruby@v1
66
+ with:
67
+ rubygems: latest
68
+ ruby-version: 'ruby'
69
+ bundler-cache: true
70
+ - name: "Download cc-test-reporter from codeclimate.com"
71
+ run: |
72
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
73
+ chmod +x ./cc-test-reporter
74
+ - name: "Report to Code Climate that we will send a coverage report."
75
+ run: ./cc-test-reporter before-build
76
+ - name: Run tests
77
+ run: bundle exec rspec
78
+ env:
79
+ COVERAGE: 1
80
+ - name: Upload code coverage to Code Climate
81
+ run: |
82
+ ./cc-test-reporter after-build \
83
+ --coverage-input-type simplecov \
84
+ ./coverage/.resultset.json
85
+
86
+ rubocop:
87
+ runs-on: ubuntu-latest
88
+ steps:
89
+ - uses: actions/checkout@v4
90
+ - name: Set up Ruby
91
+ uses: ruby/setup-ruby@v1
92
+ with:
93
+ rubygems: default
94
+ ruby-version: 'ruby'
95
+ bundler-cache: false
96
+ - run: bundle install
97
+ - name: Run RuboCop
98
+ run: bundle exec rubocop
99
+
100
+ required-checks:
101
+ runs-on: ubuntu-latest
102
+ if: ${{ always() }}
103
+ needs:
104
+ - test
105
+ - matrix-test
106
+ - rubocop
107
+ steps:
108
+ - name: failure
109
+ if: ${{ failure() || contains(needs.*.result, 'failure') }}
110
+ run: exit 1
111
+ - name: success
112
+ 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/.rubocop.yml CHANGED
@@ -1,7 +1,12 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.1
3
3
  Exclude:
4
4
  - "lib/generators/**/templates/**/*"
5
+ <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
6
+ - <%= path.sub(/^!! /, '').sub(/\/$/, '/**/*') %>
7
+ <% end %>
8
+ SuggestExtensions: false
9
+ NewCops: disable
5
10
 
6
11
  Metrics/BlockLength:
7
12
  Exclude:
@@ -15,19 +20,13 @@ Metrics/ModuleLength:
15
20
  Exclude:
16
21
  - "**/*_spec.rb"
17
22
 
18
- Metrics/LineLength:
23
+ Layout/LineLength:
19
24
  Max: 120
20
25
 
21
- Metrics/AbcSize:
22
- Enabled: false
23
-
24
- Metrics/CyclomaticComplexity:
25
- Enabled: false
26
-
27
- Metrics/PerceivedComplexity:
28
- Enabled: false
26
+ Gemspec/RequiredRubyVersion:
27
+ Enabled: false
29
28
 
30
- Layout/AlignParameters:
29
+ Layout/ParameterAlignment:
31
30
  EnforcedStyle: with_fixed_indentation
32
31
 
33
32
  Layout/CaseIndentation:
@@ -54,14 +53,11 @@ Style/StringLiteralsInInterpolation:
54
53
  Style/StructInheritance:
55
54
  Enabled: false
56
55
 
57
- Style/AndOr:
58
- Enabled: false
59
-
60
- Style/Not:
61
- Enabled: false
62
-
63
56
  Style/DoubleNegation:
64
57
  Enabled: false
65
58
 
66
- Documentation:
59
+ Style/Documentation:
67
60
  Enabled: false # TODO: Enable again once we have more docs
61
+
62
+ Style/HashSyntax:
63
+ EnforcedShorthandSyntax: never
data/CHANGELOG.md CHANGED
@@ -2,6 +2,58 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.4.0 (2024-08-26)
6
+
7
+ ## Changed
8
+
9
+ - Improve the `NotAuthorizedError` message to include the policy class.
10
+ Furthermore, in the case where the record passed is a class instead of an instance, the class name is given. (#812)
11
+
12
+ ## Added
13
+
14
+ - Add customizable permit matcher description (#806)
15
+ - Add support for filter_run_when_matching :focus with permissions helper. (#820)
16
+
17
+ ## 2.3.2 (2024-05-08)
18
+
19
+ - Refactor: First pass of Pundit::Context (#797)
20
+
21
+ ## Changed
22
+
23
+ - Update `ApplicationPolicy` generator to qualify the `Scope` class name (#792)
24
+ - Policy generator uses `NoMethodError` to indicate `#resolve` is not implemented (#776)
25
+
26
+ ## Deprecated
27
+
28
+ - Dropped support for Ruby 3.0 (#796)
29
+
30
+ ## 2.3.1 (2023-07-17)
31
+
32
+ ### Fixed
33
+
34
+ - Use `Kernel.warn` instead of `ActiveSupport::Deprecation.warn` for deprecations (#764)
35
+ - Policy generator now works on Ruby 3.2 (#754)
36
+
37
+ ## 2.3.0 (2022-12-19)
38
+
39
+ ### Added
40
+
41
+ - add support for rubocop-rspec syntax extensions (#745)
42
+
43
+ ## 2.2.0 (2022-02-11)
44
+
45
+ ### Fixed
46
+
47
+ - Using `policy_class` and a namespaced record now passes only the record when instantiating the policy. (#697, #689, #694, #666)
48
+
49
+ ### Changed
50
+
51
+ - Require users to explicitly define Scope#resolve in generated policies (#711, #722)
52
+
53
+ ### Deprecated
54
+
55
+ - Deprecate `include Pundit` in favor of `include Pundit::Authorization` (#621)
56
+
5
57
  ## 2.1.1 (2021-08-13)
6
58
 
7
59
  Friday 13th-release!
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
@@ -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 master branch.
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,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- ruby RUBY_VERSION
6
-
7
5
  gemspec
6
+
7
+ # https://github.com/ruby/psych/issues/655
8
+ gem "psych", "!= 5.1.1", platforms: %i[jruby]