From edf0e6ef7646b221743ffcb966a1af0fb2b7422c Mon Sep 17 00:00:00 2001 From: Thomas Klemm Date: Sun, 13 Jul 2014 11:16:45 +0200 Subject: [PATCH] Policy namespacing: Add spec ensuring fallback on non-namespaced policy class --- spec/pundit_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/pundit_spec.rb b/spec/pundit_spec.rb index 232c047..720b787 100644 --- a/spec/pundit_spec.rb +++ b/spec/pundit_spec.rb @@ -201,6 +201,10 @@ describe Pundit do expect(nested_controller.policy(comment).class).to eq Admin::CommentPolicy end + it "falls back to the non-namespaced policy class if there isn't a namespaced one" do + expect(nested_controller.policy(post).class).to eq PostPolicy + end + it "allows policy to be injected" do new_policy = OpenStruct.new controller.policy = new_policy