posts: fix incorrect post counts for -pool:, -fav: searches

Fix `-pool:1234` and `-fav:evazion` searches incorrectly returning the
same post count as `pool:1234` and `fav:evazion` searches.
This commit is contained in:
evazion
2022-08-28 22:50:33 -05:00
parent fa0d7990fb
commit 4448b3d15b
2 changed files with 13 additions and 6 deletions

View File

@@ -1480,14 +1480,21 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
assert_fast_count(3, "pool:#{pool.id}")
assert_fast_count(3, "pool:#{pool.name}")
assert_fast_count(3, "ordpool:#{pool.id}")
assert_fast_count(3, "ordpool:#{pool.name}")
assert_fast_count(Post.count, "-pool:#{pool.id}")
assert_fast_count(Post.count, "-pool:#{pool.name}")
end
should "return the correct favorite count for a fav:<name> search" do
fav = create(:favorite)
fav.user.update!(favorite_count: 1)
User.where(id: fav.user).update_all(favorite_count: 42) # XXX favorite_count is readonly; update it this way to bypass the readonly check.
assert_fast_count(1, "fav:#{fav.user.name}")
assert_fast_count(1, "ordfav:#{fav.user.name}")
assert_fast_count(42, "fav:#{fav.user.name}")
assert_fast_count(42, "ordfav:#{fav.user.name}")
assert_fast_count(1, "-fav:#{fav.user.name}")
end
should "return the correct favorite count for a fav:<name> search for a user with private favorites" do