mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
Fix rubocop issues
This makes rubocop work with newer versions.
This commit is contained in:
parent
001d3fc16d
commit
70935c5e93
6 changed files with 11 additions and 12 deletions
|
@ -82,10 +82,10 @@ Layout/IndentationWidth:
|
|||
Style/TrivialAccessors:
|
||||
ExactNameMatch: true
|
||||
|
||||
Lint/EndAlignment:
|
||||
Layout/EndAlignment:
|
||||
EnforcedStyleAlignWith: variable
|
||||
|
||||
Lint/DefEndAlignment:
|
||||
Layout/DefEndAlignment:
|
||||
Enabled: false
|
||||
|
||||
Lint/HandleExceptions:
|
||||
|
|
|
@ -8,6 +8,3 @@
|
|||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Lint/UnneededDisable:
|
||||
Exclude:
|
||||
- 'lib/pundit/rspec.rb'
|
||||
|
|
|
@ -63,9 +63,7 @@ module Pundit
|
|||
def authorize(user, record, query)
|
||||
policy = policy!(user, record)
|
||||
|
||||
unless policy.public_send(query)
|
||||
raise NotAuthorizedError, query: query, record: record, policy: policy
|
||||
end
|
||||
raise NotAuthorizedError, query: query, record: record, policy: policy unless policy.public_send(query)
|
||||
|
||||
record
|
||||
end
|
||||
|
@ -183,9 +181,7 @@ protected
|
|||
|
||||
policy = policy(record)
|
||||
|
||||
unless policy.public_send(query)
|
||||
raise NotAuthorizedError, query: query, record: record, policy: policy
|
||||
end
|
||||
raise NotAuthorizedError, query: query, record: record, policy: policy unless policy.public_send(query)
|
||||
|
||||
record
|
||||
end
|
||||
|
@ -250,16 +246,20 @@ protected
|
|||
# Cache of policies. You should not rely on this method.
|
||||
#
|
||||
# @api private
|
||||
# rubocop:disable Naming/MemoizedInstanceVariableName
|
||||
def policies
|
||||
@_pundit_policies ||= {}
|
||||
end
|
||||
# rubocop:enable Naming/MemoizedInstanceVariableName
|
||||
|
||||
# Cache of policy scope. You should not rely on this method.
|
||||
#
|
||||
# @api private
|
||||
# rubocop:disable Naming/MemoizedInstanceVariableName
|
||||
def policy_scopes
|
||||
@_pundit_policy_scopes ||= {}
|
||||
end
|
||||
# rubocop:enable Naming/MemoizedInstanceVariableName
|
||||
|
||||
# Hook method which allows customizing which user is passed to policies and
|
||||
# scopes initialized by {#authorize}, {#policy} and {#policy_scope}.
|
||||
|
|
|
@ -50,6 +50,7 @@ module Pundit
|
|||
current_example.metadata[:permissions]
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/BlockLength
|
||||
end
|
||||
|
||||
module DSL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
lib = File.expand_path("../lib", __FILE__)
|
||||
lib = File.expand_path("lib", __dir__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require "pundit/version"
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ describe Pundit do
|
|||
expect(error.record).to eq post
|
||||
expect(error.policy).to eq Pundit.policy(user, post)
|
||||
end
|
||||
# rubocop:enable Style/MultilineBlockChain
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue