Skip to content

Commit

Permalink
fix: ensure Pundit default policy continues to raise `NotImplementedE…
Browse files Browse the repository at this point in the history
…rror`
  • Loading branch information
G-Rath committed May 9, 2024
1 parent 86d736f commit 0b8d1c3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions variants/pundit/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
run "rails g pundit:install"
run "rails g pundit:policy example"

# Pundit uses NoMethodError which is easier to catch as it extends from StandardError,
# but it's technically not correct as our class does respond to the method in question
#
# For now, we're just going to stick with the more traditional error for this situation
gsub_file! "app/policies/application_policy.rb", "raise NoMethodError", "raise NotImplementedError"

# "raise NotImplementedError, "You must define #resolve in #{self.class}""

copy_file "spec/policies/example_policy_spec.rb", force: true
copy_file "spec/policies/application_policy_spec.rb", force: true

Expand Down

0 comments on commit 0b8d1c3

Please sign in to comment.