diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index 08aaa7d94..b46acb631 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -31,7 +31,7 @@ class PostFlag < ApplicationRecord def creator_matches(creator, searcher) return none if creator.nil? - policy = Pundit.policy!(searcher, PostFlag.new(creator: creator)) + policy = Pundit.policy!(searcher, PostFlag.unscoped.new(creator: creator)) if policy.can_view_flagger? where(creator: creator).where.not(post: searcher.posts) diff --git a/test/functional/post_flags_controller_test.rb b/test/functional/post_flags_controller_test.rb index 31a930f45..64c50bd55 100644 --- a/test/functional/post_flags_controller_test.rb +++ b/test/functional/post_flags_controller_test.rb @@ -105,6 +105,8 @@ class PostFlagsControllerTest < ActionDispatch::IntegrationTest end should respond_to_search(creator_id: 999).with { @post_flag } + should respond_to_search(creator_id: 999, status: "pending").with { @post_flag } + should respond_to_search(creator_id: 999, status: PostFlag.statuses["pending"].to_s).with { @post_flag } end end