mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
Merge pull request #583 from brendanthomas1/return-safer-not-authorized-message
return a safer default NotAuthorizedError message
This commit is contained in:
commit
bd188470f9
2 changed files with 2 additions and 2 deletions
|
@ -30,7 +30,7 @@ module Pundit
|
|||
@record = options[:record]
|
||||
@policy = options[:policy]
|
||||
|
||||
message = options.fetch(:message) { "not allowed to #{query} this #{record.inspect}" }
|
||||
message = options.fetch(:message) { "not allowed to #{query} this #{record.class}" }
|
||||
end
|
||||
|
||||
super(message)
|
||||
|
|
|
@ -36,7 +36,7 @@ describe Pundit do
|
|||
# rubocop:disable Style/MultilineBlockChain
|
||||
expect do
|
||||
Pundit.authorize(user, post, :destroy?)
|
||||
end.to raise_error(Pundit::NotAuthorizedError, "not allowed to destroy? this #<Post>") do |error|
|
||||
end.to raise_error(Pundit::NotAuthorizedError, "not allowed to destroy? this Post") do |error|
|
||||
expect(error.query).to eq :destroy?
|
||||
expect(error.record).to eq post
|
||||
expect(error.policy).to eq Pundit.policy(user, post)
|
||||
|
|
Loading…
Reference in a new issue