Initial install of action policy
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -80,3 +80,5 @@ gem "authentication-zero", "~> 3.0"
|
||||
|
||||
# Use Pwned to check if a password has been found in any of the huge data breaches [https://github.com/philnash/pwned]
|
||||
gem "pwned"
|
||||
|
||||
gem "action_policy", "~> 0.7.1"
|
||||
|
||||
12
Gemfile.lock
12
Gemfile.lock
@@ -2,6 +2,8 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
Ascii85 (1.1.1)
|
||||
action_policy (0.7.1)
|
||||
ruby-next-core (>= 1.0)
|
||||
actioncable (7.2.1)
|
||||
actionpack (= 7.2.1)
|
||||
activesupport (= 7.2.1)
|
||||
@@ -162,7 +164,7 @@ GEM
|
||||
mini_mime (1.1.5)
|
||||
minitest (5.25.1)
|
||||
msgpack (1.7.2)
|
||||
net-imap (0.4.15)
|
||||
net-imap (0.4.16)
|
||||
date
|
||||
net-protocol
|
||||
net-pop (0.1.2)
|
||||
@@ -247,7 +249,7 @@ GEM
|
||||
redis-client (0.22.2)
|
||||
connection_pool
|
||||
regexp_parser (2.9.2)
|
||||
reline (0.5.9)
|
||||
reline (0.5.10)
|
||||
io-console (~> 0.5)
|
||||
rexml (3.3.7)
|
||||
rubocop (1.66.1)
|
||||
@@ -260,7 +262,7 @@ GEM
|
||||
rubocop-ast (>= 1.32.2, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.32.2)
|
||||
rubocop-ast (1.32.3)
|
||||
parser (>= 3.3.1.0)
|
||||
rubocop-minitest (0.36.0)
|
||||
rubocop (>= 1.61, < 2.0)
|
||||
@@ -268,7 +270,7 @@ GEM
|
||||
rubocop-performance (1.21.1)
|
||||
rubocop (>= 1.48.1, < 2.0)
|
||||
rubocop-ast (>= 1.31.1, < 2.0)
|
||||
rubocop-rails (2.26.0)
|
||||
rubocop-rails (2.26.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.52.0, < 2.0)
|
||||
@@ -278,6 +280,7 @@ GEM
|
||||
rubocop-minitest
|
||||
rubocop-performance
|
||||
rubocop-rails
|
||||
ruby-next-core (1.0.3)
|
||||
ruby-progressbar (1.13.0)
|
||||
ruby-rc4 (0.1.5)
|
||||
ruby-vips (2.2.2)
|
||||
@@ -354,6 +357,7 @@ PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
action_policy (~> 0.7.1)
|
||||
authentication-zero (~> 3.0)
|
||||
bcrypt (~> 3.1.7)
|
||||
bootsnap
|
||||
|
||||
18
app/policies/application_policy.rb
Normal file
18
app/policies/application_policy.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# Base class for application policies
|
||||
class ApplicationPolicy < ActionPolicy::Base
|
||||
# Configure additional authorization contexts here
|
||||
# (`user` is added by default).
|
||||
#
|
||||
# authorize :account, optional: true
|
||||
#
|
||||
# Read more about authorization context: https://actionpolicy.evilmartians.io/#/authorization_context
|
||||
|
||||
private
|
||||
|
||||
# Define shared methods useful for most policies.
|
||||
# For example:
|
||||
#
|
||||
# def owner?
|
||||
# record.user_id == user.id
|
||||
# end
|
||||
end
|
||||
20
app/policies/job_policy.rb
Normal file
20
app/policies/job_policy.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class JobPolicy < ApplicationPolicy
|
||||
# See https://actionpolicy.evilmartians.io/#/writing_policies
|
||||
#
|
||||
# def index?
|
||||
# true
|
||||
# end
|
||||
#
|
||||
# def update?
|
||||
# # here we can access our context and record
|
||||
# user.admin? || (user.id == record.user_id)
|
||||
# end
|
||||
|
||||
# Scoping
|
||||
# See https://actionpolicy.evilmartians.io/#/scoping
|
||||
#
|
||||
# relation_scope do |relation|
|
||||
# next relation if user.admin?
|
||||
# relation.where(user: user)
|
||||
# end
|
||||
end
|
||||
13
test/policies/job_policy_test.rb
Normal file
13
test/policies/job_policy_test.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
require "test_helper"
|
||||
|
||||
# See https://actionpolicy.evilmartians.io/#/testing?id=testing-policies
|
||||
class JobPolicyTest < ActiveSupport::TestCase
|
||||
def test_index
|
||||
end
|
||||
|
||||
def test_create
|
||||
end
|
||||
|
||||
def test_manage
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user