From db1e341cfaa600c63c5c6cb62b067ad84490130d Mon Sep 17 00:00:00 2001 From: Rafael Santos Date: Tue, 5 Jul 2016 15:21:00 +1200 Subject: [PATCH] document features to be implemented --- spec/pundit_spec.rb | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/spec/pundit_spec.rb b/spec/pundit_spec.rb index 0b752ad9..4804c55d 100644 --- a/spec/pundit_spec.rb +++ b/spec/pundit_spec.rb @@ -38,7 +38,13 @@ end end + describe ".authorize_scope" do + it "infers and applies a scope based on it" + end + describe ".policy_scope" do + it "becomes a call to #authorized_scope(scope, :resolve)" + it "returns an instantiated policy scope given a plain model class" do expect(Pundit.policy_scope(user, Post)).to eq :published end @@ -88,6 +94,14 @@ end end + describe ".scope_policy" do + it "returns an instantiated scope policy given a scope" + end + + describe ".scope_policy!" do + it "does whatever it have to be done" + end + describe ".policy" do it "returns an instantiated policy given a plain model instance" do policy = Pundit.policy(user, post) @@ -296,6 +310,19 @@ end end + describe "#verify_scope_authorized" do + it "does nothing when policy_scope is used" do + pending + controller.authorize_scope(Post) + controller.verify_scope_authorized + end + + it "raises an exception when policy_scope is not used" do + pending + expect { controller.verify_scope_authorized }.to raise_error(Pundit::PolicyScopingNotPerformedError) + end + end + describe "#verify_policy_scoped" do it "does nothing when policy_scope is used" do controller.policy_scope(Post) @@ -329,6 +356,19 @@ end end + describe "#pundit_scope_policy_authorized?" do + it "is true when policy_scope is used" do + pending + controller.authorize_scope(Post) + expect(controller.pundit_policy_scope_authorized?).to be true + end + + it "is false when policy scope is not used" do + pending + expect(controller.pundit_policy_scope_authorized?).to be false + end + end + describe "#authorize" do it "infers the policy name and authorizes based on it" do expect(controller.authorize(post)).to be_truthy @@ -374,6 +414,14 @@ end end + describe "#authorize_scope" do + it "infers the policy name and authorizes based on it" + end + + describe "#skip_scope_authorization" do + it "disables scope policy verification" + end + describe "#skip_policy_scope" do it "disables policy scope verification" do controller.skip_policy_scope @@ -406,7 +454,13 @@ end end + describe "#scope_policy" do + it "returns an instantiated scope policy" + end + describe "#policy_scope" do + it "becomes a call to #authorized_scope(scope, :resolve)" + it "returns an instantiated policy scope" do expect(controller.policy_scope(Post)).to eq :published end