search: fix invalid username searches returning wrong results.

Partial fix for #4389.

* Fix invalid username searches returning all posts instead of no posts.
* Fix "user:A user:B" returning results for user:B instead of no results.
* Fix "approver:A approver:B" returning results for approver:B instead of no results.
* Add support for negated -commenter, -noter, -noteupdater, -upvote, -downvote metatags.
* Add support for "any" and "none" values for all username metatags,
  including negated metatags that didn't support "any" or "none" before.
* Change noter:any and commenter:any to include posts with deleted notes
  or comments. Note that commenter:<username> already included deleted
  comments before. This is so that commenter:any has the same behavior
  as commenter:<username>
This commit is contained in:
evazion
2020-04-15 00:13:07 -05:00
parent dc6575dc76
commit be27423afd
5 changed files with 144 additions and 173 deletions

View File

@@ -2133,8 +2133,8 @@ class PostTest < ActiveSupport::TestCase
create(:comment, creator: create(:user, created_at: 2.weeks.ago), post: posts[0], is_deleted: false)
create(:comment, creator: create(:user, created_at: 2.weeks.ago), post: posts[1], is_deleted: true)
assert_tag_match([posts[0]], "commenter:any")
assert_tag_match([posts[1]], "commenter:none")
assert_tag_match(posts.reverse, "commenter:any")
assert_tag_match([], "commenter:none")
end
should "return posts for the noter:<name> metatag" do
@@ -2153,8 +2153,8 @@ class PostTest < ActiveSupport::TestCase
FactoryBot.create(:note, post: posts[0], is_active: true)
FactoryBot.create(:note, post: posts[1], is_active: false)
assert_tag_match([posts[0]], "noter:any")
assert_tag_match([posts[1]], "noter:none")
assert_tag_match(posts.reverse, "noter:any")
assert_tag_match([], "noter:none")
end
should "return posts for the note_count:<N> metatag" do