Created
November 14, 2023 11:11
-
-
Save ImMaax/661b004333fc2472c493709171507fc7 to your computer and use it in GitHub Desktop.
Pundit Minitest Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Insert into Rails' test_helper.rb or wherever else you place your test helpers | |
# Can be used like so: | |
# assert permits? :show?, User.new, Record.new | |
def permits?(action, user, record) | |
policy = "#{record.class.name}Policy".constantize.new user, record | |
policy.send action | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment