action_policy 0.3.3 → 0.3.4
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/CHANGELOG.md +7 -0
- data/lib/action_policy/version.rb +1 -1
- data/lib/generators/action_policy/install/USAGE +1 -1
- data/lib/generators/action_policy/install/templates/application_policy.rb +16 -0
- data/lib/generators/action_policy/policy/policy_generator.rb +4 -1
- data/lib/generators/{action_policy/rspec → rspec}/policy_generator.rb +0 -0
- data/lib/generators/{action_policy/rspec → rspec}/templates/policy_spec.rb +3 -1
- data/lib/generators/{action_policy/test_unit → test_unit}/policy_generator.rb +0 -0
- data/lib/generators/{action_policy/test_unit → test_unit}/templates/policy_test.rb +2 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 272123a33fae55ffd9e6e09b1098862fbbf353a6ed5ff71d090bc5fd01396244
|
4
|
+
data.tar.gz: ec53e2634999660b46c95dddc85bcf71055e336fdae5a8ea47023a671bba55ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62353ff2be45386257efcd127a43c7eac61d1cb7fc3cfcbf1acc6d6563e6d0a0a91873a0593b8ff62d51adc70b730e1799eb5a1565e3a1ed3c1f2593d46a05ff
|
7
|
+
data.tar.gz: 837e717de9323e7131c535a41fe848aaa9501ad8f10471f082ff1355ae824afa7691b44bb9c8db71cb0b33898ad126963f3518b8cfcc1207e34469a282648d62
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## master
|
2
2
|
|
3
|
+
## 0.3.4 (2019-11-27)
|
4
|
+
|
5
|
+
- Fix Rails generators. ([@palkan][])
|
6
|
+
|
7
|
+
Only invoke install generator if `application_policy.rb` is missing.
|
8
|
+
Fix hooking into test frameworks.
|
9
|
+
|
3
10
|
## 0.3.3 (2019-11-27)
|
4
11
|
|
5
12
|
- Improve pretty print functionality. ([@palkan][])
|
@@ -1,2 +1,2 @@
|
|
1
1
|
Description:
|
2
|
-
Generates
|
2
|
+
Generates a base policy class (ApplicationPolicy) for your application.
|
@@ -1,2 +1,18 @@
|
|
1
|
+
# Base class for application policies
|
1
2
|
class ApplicationPolicy < ActionPolicy::Base
|
3
|
+
# Configure additional authorization contexts here
|
4
|
+
# (`user` is added by default).
|
5
|
+
#
|
6
|
+
# authorize :account, optional: true
|
7
|
+
#
|
8
|
+
# Read more about authoriztion context: https://actionpolicy.evilmartians.io/#/authorization_context
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Define shared methods useful for most policies.
|
13
|
+
# For example:
|
14
|
+
#
|
15
|
+
# def owner?
|
16
|
+
# record.user_id == user.id
|
17
|
+
# end
|
2
18
|
end
|
@@ -7,7 +7,10 @@ module ActionPolicy
|
|
7
7
|
class PolicyGenerator < ::Rails::Generators::NamedBase
|
8
8
|
source_root File.expand_path("templates", __dir__)
|
9
9
|
|
10
|
-
|
10
|
+
def run_install_if_needed
|
11
|
+
return if ::Rails.root.join("app/policies/application_policy.rb").exist?
|
12
|
+
generate "action_policy:install"
|
13
|
+
end
|
11
14
|
|
12
15
|
def create_policy
|
13
16
|
template "policy.rb", File.join("app/policies", class_path, "#{file_name}_policy.rb")
|
File without changes
|
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "<%= File.exists?('spec/rails_helper.rb') ? 'rails_helper' : 'spec_helper' %>"
|
2
2
|
|
3
3
|
RSpec.describe <%= class_name %>Policy, type: :policy do
|
4
|
+
# See https://actionpolicy.evilmartians.io/#/testing?id=rspec-dsl
|
5
|
+
#
|
4
6
|
# let(:user) { build_stubbed :user }
|
5
7
|
# let(:record) { build_stubbed :post, draft: false }
|
6
8
|
# let(:context) { {user: user} }
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_policy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
@@ -273,10 +273,10 @@ files:
|
|
273
273
|
- lib/generators/action_policy/policy/USAGE
|
274
274
|
- lib/generators/action_policy/policy/policy_generator.rb
|
275
275
|
- lib/generators/action_policy/policy/templates/policy.rb
|
276
|
-
- lib/generators/
|
277
|
-
- lib/generators/
|
278
|
-
- lib/generators/
|
279
|
-
- lib/generators/
|
276
|
+
- lib/generators/rspec/policy_generator.rb
|
277
|
+
- lib/generators/rspec/templates/policy_spec.rb
|
278
|
+
- lib/generators/test_unit/policy_generator.rb
|
279
|
+
- lib/generators/test_unit/templates/policy_test.rb
|
280
280
|
homepage: https://github.com/palkan/action_policy
|
281
281
|
licenses:
|
282
282
|
- MIT
|