Fix #4609: Searching for users failed flags fails.
This commit is contained in:
@@ -31,7 +31,7 @@ class PostFlag < ApplicationRecord
|
|||||||
def creator_matches(creator, searcher)
|
def creator_matches(creator, searcher)
|
||||||
return none if creator.nil?
|
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?
|
if policy.can_view_flagger?
|
||||||
where(creator: creator).where.not(post: searcher.posts)
|
where(creator: creator).where.not(post: searcher.posts)
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ class PostFlagsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
should respond_to_search(creator_id: 999).with { @post_flag }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user