From b9d4be16c895cd56f1bde5b76adf509fe93c7b02 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 19 Jan 2022 22:56:51 -0600 Subject: [PATCH] Fix #4609: Searching for users failed flags fails. --- app/models/post_flag.rb | 2 +- test/functional/post_flags_controller_test.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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