Skip to content

Instantly share code, notes, and snippets.

@ImMaax
Created November 14, 2023 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImMaax/661b004333fc2472c493709171507fc7 to your computer and use it in GitHub Desktop.
Save ImMaax/661b004333fc2472c493709171507fc7 to your computer and use it in GitHub Desktop.
Pundit Minitest Helper
# 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