spec/pundit_spec.rb in pundit-0.2.0 vs spec/pundit_spec.rb in pundit-0.2.1

- old
+ new

@@ -1,7 +1,8 @@ require "pundit" require "pry" +require "active_support/core_ext" require "active_model/naming" class PostPolicy < Struct.new(:user, :post) def update? post.user == user @@ -189,9 +190,20 @@ controller.verify_authorized end it "raises an exception when not authorized" do expect { controller.verify_authorized }.to raise_error(Pundit::NotAuthorizedError) + end + end + + describe "#verify_policy_scoped" do + it "does nothing when policy_scope is used" do + controller.policy_scope(Post) + controller.verify_policy_scoped + end + + it "raises an exception when policy_scope is not used" do + expect { controller.verify_policy_scoped }.to raise_error(Pundit::NotAuthorizedError) end end describe "#authorize" do it "infers the policy name and authorized based on it" do