Fix #4609: Searching for users failed flags fails.

This commit is contained in:
evazion
2022-01-19 22:56:51 -06:00
parent 0db20e0cab
commit b9d4be16c8
2 changed files with 3 additions and 1 deletions

View File

@@ -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)

View File

@@ -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