1
0
Fork 0
mirror of https://github.com/varvet/pundit.git synced 2022-11-09 12:30:11 -05:00

Policy namespacing: Add spec ensuring fallback on non-namespaced policy class

This commit is contained in:
Thomas Klemm 2014-07-13 11:16:45 +02:00
parent 7ebc33e112
commit edf0e6ef76

View file

@ -201,6 +201,10 @@ describe Pundit do
expect(nested_controller.policy(comment).class).to eq Admin::CommentPolicy expect(nested_controller.policy(comment).class).to eq Admin::CommentPolicy
end 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 it "allows policy to be injected" do
new_policy = OpenStruct.new new_policy = OpenStruct.new
controller.policy = new_policy controller.policy = new_policy