Skip to content

Commit

Permalink
Merge pull request #835 from varvet/kbs/move-suffix-to-its-owner
Browse files Browse the repository at this point in the history
Move `Pundit::SUFFIX` to `Pundit::PolicyFinder::SUFFIX`
  • Loading branch information
Burgestrand authored Oct 24, 2024
2 parents 3bb2021 + 3010964 commit 2b0ca28
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## Changed

- Deprecated `Pundit::SUFFIX`, moved it to `Pundit::PolicyFinder::SUFFIX` (#835)

## 2.4.0 (2024-08-26)

## Changed
Expand Down
4 changes: 3 additions & 1 deletion lib/pundit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/pundit/policy_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/policy_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down

0 comments on commit 2b0ca28

Please sign in to comment.