pundit 1.1.0 → 2.3.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 +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +29 -52
- data/.travis.yml +25 -10
- data/CHANGELOG.md +88 -0
- data/Gemfile +4 -1
- data/LICENSE.txt +1 -1
- data/README.md +304 -87
- data/Rakefile +2 -1
- data/config/rubocop-rspec.yml +5 -0
- data/lib/generators/pundit/install/install_generator.rb +4 -2
- data/lib/generators/pundit/install/templates/application_policy.rb +8 -8
- data/lib/generators/pundit/policy/policy_generator.rb +4 -2
- data/lib/generators/pundit/policy/templates/policy.rb +4 -3
- data/lib/generators/rspec/policy_generator.rb +4 -2
- data/lib/generators/rspec/templates/policy_spec.rb +1 -2
- data/lib/generators/test_unit/policy_generator.rb +4 -2
- data/lib/generators/test_unit/templates/policy_test.rb +0 -1
- data/lib/pundit/authorization.rb +168 -0
- data/lib/pundit/policy_finder.rb +28 -32
- data/lib/pundit/rspec.rb +13 -17
- data/lib/pundit/version.rb +3 -1
- data/lib/pundit.rb +76 -190
- data/pundit.gemspec +12 -9
- data/spec/authorization_spec.rb +258 -0
- data/spec/generators_spec.rb +43 -0
- data/spec/policies/post_policy_spec.rb +3 -1
- data/spec/policy_finder_spec.rb +187 -0
- data/spec/pundit_spec.rb +147 -196
- data/spec/spec_helper.rb +110 -30
- metadata +59 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
2
3
|
Exclude:
|
3
|
-
- "
|
4
|
-
|
5
|
-
|
4
|
+
- "lib/generators/**/templates/**/*"
|
5
|
+
SuggestExtensions: false
|
6
|
+
NewCops: disable
|
7
|
+
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- "**/*_spec.rb"
|
6
11
|
|
7
12
|
Metrics/MethodLength:
|
8
13
|
Max: 40
|
9
14
|
|
10
15
|
Metrics/ModuleLength:
|
11
16
|
Max: 200
|
17
|
+
Exclude:
|
18
|
+
- "**/*_spec.rb"
|
12
19
|
|
13
|
-
|
20
|
+
Layout/LineLength:
|
14
21
|
Max: 120
|
15
22
|
|
16
23
|
Metrics/AbcSize:
|
@@ -22,74 +29,44 @@ Metrics/CyclomaticComplexity:
|
|
22
29
|
Metrics/PerceivedComplexity:
|
23
30
|
Enabled: false
|
24
31
|
|
25
|
-
|
26
|
-
|
32
|
+
Gemspec/RequiredRubyVersion:
|
33
|
+
Enabled: false
|
27
34
|
|
28
|
-
|
35
|
+
Layout/ParameterAlignment:
|
29
36
|
EnforcedStyle: with_fixed_indentation
|
30
37
|
|
31
|
-
|
32
|
-
EnforcedStyle:
|
33
|
-
|
34
|
-
Style/StringLiteralsInInterpolation:
|
35
|
-
EnforcedStyle: double_quotes
|
36
|
-
|
37
|
-
Style/ClosingParenthesisIndentation:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
Style/OneLineConditional:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
Style/AndOr:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
Style/Not:
|
47
|
-
Enabled: false
|
48
|
-
|
49
|
-
Documentation:
|
50
|
-
Enabled: false # TODO: Enable again once we have more docs
|
51
|
-
|
52
|
-
Style/CaseIndentation:
|
53
|
-
IndentWhenRelativeTo: case
|
38
|
+
Layout/CaseIndentation:
|
39
|
+
EnforcedStyle: case
|
54
40
|
SupportedStyles:
|
55
41
|
- case
|
56
42
|
- end
|
57
43
|
IndentOneStep: true
|
58
44
|
|
45
|
+
Layout/EndAlignment:
|
46
|
+
EnforcedStyleAlignWith: variable
|
47
|
+
|
59
48
|
Style/PercentLiteralDelimiters:
|
60
49
|
PreferredDelimiters:
|
61
50
|
'%w': "[]"
|
62
51
|
'%W': "[]"
|
63
52
|
|
64
|
-
Style/
|
65
|
-
EnforcedStyle:
|
66
|
-
|
67
|
-
Style/SignalException:
|
68
|
-
Enabled: false
|
69
|
-
|
70
|
-
Style/IndentationWidth:
|
71
|
-
Enabled: false
|
72
|
-
|
73
|
-
Style/TrivialAccessors:
|
74
|
-
ExactNameMatch: true
|
75
|
-
|
76
|
-
Lint/EndAlignment:
|
77
|
-
AlignWith: variable
|
78
|
-
|
79
|
-
Lint/DefEndAlignment:
|
80
|
-
Enabled: false
|
53
|
+
Style/StringLiterals:
|
54
|
+
EnforcedStyle: double_quotes
|
81
55
|
|
82
|
-
|
83
|
-
|
56
|
+
Style/StringLiteralsInInterpolation:
|
57
|
+
EnforcedStyle: double_quotes
|
84
58
|
|
85
|
-
Style/
|
59
|
+
Style/StructInheritance:
|
86
60
|
Enabled: false
|
87
61
|
|
88
|
-
Style/
|
62
|
+
Style/AndOr:
|
89
63
|
Enabled: false
|
90
64
|
|
91
|
-
Style/
|
65
|
+
Style/Not:
|
92
66
|
Enabled: false
|
93
67
|
|
94
68
|
Style/DoubleNegation:
|
95
69
|
Enabled: false
|
70
|
+
|
71
|
+
Style/Documentation:
|
72
|
+
Enabled: false # TODO: Enable again once we have more docs
|
data/.travis.yml
CHANGED
@@ -1,11 +1,26 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
dist: focal
|
3
|
+
|
4
|
+
matrix:
|
5
|
+
include:
|
6
|
+
- name: "RuboCop lint on pre-installed Ruby version"
|
7
|
+
rvm: 2.7.1 # Pre-installed Ruby version
|
8
|
+
before_install:
|
9
|
+
- gem install bundler
|
10
|
+
script: bundle exec rake rubocop # ONLY lint once, first
|
11
|
+
- rvm: 2.6.7
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
16
|
+
after_script:
|
17
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
18
|
+
- rvm: 2.7.3
|
19
|
+
- rvm: 3.0.1
|
20
|
+
- rvm: 3.1.0
|
21
|
+
- rvm: jruby-9.2.17.0
|
22
|
+
env:
|
23
|
+
- JRUBY_OPTS="--debug"
|
24
|
+
- rvm: truffleruby-head
|
25
|
+
allow_failures:
|
26
|
+
- rvm: truffleruby-head
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,93 @@
|
|
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
|
+
|
9
|
+
## 2.2.0 (2022-02-11)
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Using `policy_class` and a namespaced record now passes only the record when instantiating the policy. (#697, #689, #694, #666)
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Require users to explicitly define Scope#resolve in generated policies (#711, #722)
|
18
|
+
|
19
|
+
### Deprecated
|
20
|
+
|
21
|
+
- Deprecate `include Pundit` in favor of `include Pundit::Authorization` (#621)
|
22
|
+
|
23
|
+
## 2.1.1 (2021-08-13)
|
24
|
+
|
25
|
+
Friday 13th-release!
|
26
|
+
|
27
|
+
Careful! The bugfix below (#626) could break existing code. If you rely on the
|
28
|
+
return value for `authorize` and namespaced policies you might need to do some
|
29
|
+
changes.
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
- `.authorize` and `#authorize` return the instance, even for namespaced
|
34
|
+
policies (#626)
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
|
38
|
+
- Generate application scope with `protected` attr_readers. (#616)
|
39
|
+
|
40
|
+
### Removed
|
41
|
+
|
42
|
+
- Dropped support for Ruby end-of-life versions: 2.1 and 2.2. (#604)
|
43
|
+
- Dropped support for Ruby end-of-life versions: 2.3 (#633)
|
44
|
+
- Dropped support for Ruby end-of-life versions: 2.4, 2.5 and JRuby 9.1 (#676)
|
45
|
+
- Dropped support for RSpec 2 (#615)
|
46
|
+
|
47
|
+
## 2.1.0 (2019-08-14)
|
48
|
+
|
49
|
+
### Fixed
|
50
|
+
|
51
|
+
- Avoid name clashes with the Error class. (#590)
|
52
|
+
|
53
|
+
### Changed
|
54
|
+
|
55
|
+
- Return a safer default NotAuthorizedError message. (#583)
|
56
|
+
|
57
|
+
## 2.0.1 (2019-01-18)
|
58
|
+
|
59
|
+
### Breaking changes
|
60
|
+
|
61
|
+
None
|
62
|
+
|
63
|
+
### Other changes
|
64
|
+
|
65
|
+
- Improve exception handling for `#policy_scope` and `#policy_scope!`. (#550)
|
66
|
+
- Add `:policy` metadata to RSpec template. (#566)
|
67
|
+
|
68
|
+
## 2.0.0 (2018-07-21)
|
69
|
+
|
70
|
+
No changes since beta1
|
71
|
+
|
72
|
+
## 2.0.0.beta1 (2018-07-04)
|
73
|
+
|
74
|
+
### Breaking changes
|
75
|
+
|
76
|
+
- Only pass last element of "namespace array" to policy and scope. (#529)
|
77
|
+
- Raise `InvalidConstructorError` if a policy or policy scope with an invalid constructor is called. (#462)
|
78
|
+
- Return passed object from `#authorize` method to make chaining possible. (#385)
|
79
|
+
|
80
|
+
### Other changes
|
81
|
+
|
82
|
+
- Add `policy_class` option to `authorize` to be able to override the policy. (#441)
|
83
|
+
- Add `policy_scope_class` option to `authorize` to be able to override the policy scope. (#441)
|
84
|
+
- Fix `param_key` issue when passed an array. (#529)
|
85
|
+
- Allow specification of a `NilClassPolicy`. (#525)
|
86
|
+
- Make sure `policy_class` override is called when passed an array. (#475)
|
87
|
+
|
88
|
+
- Use `action_name` instead of `params[:action]`. (#419)
|
89
|
+
- Add `pundit_params_for` method to make it easy to customize params fetching. (#502)
|
90
|
+
|
3
91
|
## 1.1.0 (2016-01-14)
|
4
92
|
|
5
93
|
- Can retrieve policies via an array of symbols/objects.
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED