diff --git a/CHANGELOG.md b/CHANGELOG.md index b16cddbc..d83e138e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## Changed + +- Deprecated `Pundit::SUFFIX`, moved it to `Pundit::PolicyFinder::SUFFIX` (#835) + ## 2.4.0 (2024-08-26) ## Changed diff --git a/lib/pundit.rb b/lib/pundit.rb index a7263b39..4f143086 100644 --- a/lib/pundit.rb +++ b/lib/pundit.rb @@ -19,7 +19,9 @@ class Pundit::Error < StandardError; end # rubocop:disable Style/ClassAndModuleC # @api public module Pundit - SUFFIX = "Policy" + # @api private + # @deprecated See {Pundit::PolicyFinder} + SUFFIX = Pundit::PolicyFinder::SUFFIX # @api private # @private diff --git a/lib/pundit/policy_finder.rb b/lib/pundit/policy_finder.rb index ecc6e9bb..b63e7276 100644 --- a/lib/pundit/policy_finder.rb +++ b/lib/pundit/policy_finder.rb @@ -10,6 +10,9 @@ module Pundit # finder.scope #=> UserPolicy::Scope # class PolicyFinder + # @api private + SUFFIX = "Policy" + attr_reader :object # @param object [any] the object to find policy and scope classes for diff --git a/spec/policy_finder_spec.rb b/spec/policy_finder_spec.rb index c387b024..2f89e04f 100644 --- a/spec/policy_finder_spec.rb +++ b/spec/policy_finder_spec.rb @@ -8,6 +8,11 @@ let(:comment) { CommentFourFiveSix.new } let(:article) { Article.new } + describe "SUFFIX" do + specify { expect(described_class::SUFFIX).to eq "Policy" } + specify { expect(Pundit::SUFFIX).to eq(described_class::SUFFIX) } + end + describe "#scope" do subject { described_class.new(post) }