Fix #5057: Modqueue: filtering by tag breaks ordering
Fix the order dropdown box on the modqueue page not working when filtering by tag. This happened because when you do a tag search, the default order is set to `ORDER BY posts.id DESC`. When you applied another order with the dropdown box, the new order would be tacked on to the old ordering as a tiebreaker instead of replacing it, producing e.g. `ORDER BY posts.id DESC, queued_at DESC` instead of `ORDER BY queued_at DESC`. The default order would always win because `posts.id` is unique and doesn't have ties. The fix is to have orders always override the previous order instead of adding to it. Note that now if you use an `order:`, `ordfav:`, or `ordpool:` metatag in the search box on the modqueue page, they will always be ignored in favor of the dropdown box.
This commit is contained in:
@@ -26,6 +26,17 @@ class ModqueueControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal([{ "rating" => @post.rating }], response.parsed_body)
|
||||
end
|
||||
|
||||
should "order posts correctly when searching for tags" do
|
||||
post1 = create(:post, tag_string: "touhou", is_pending: true, score: 5)
|
||||
post2 = create(:post, tag_string: "touhou", is_pending: true, score: 10)
|
||||
post3 = create(:post, tag_string: "touhou", is_pending: true, score: 15)
|
||||
|
||||
get_auth modqueue_index_path(search: { tags: "touhou", order: "score_asc" }), @admin, as: :json
|
||||
|
||||
assert_response :success
|
||||
assert_equal([post1.id, post2.id, post3.id], response.parsed_body.pluck("id"))
|
||||
end
|
||||
|
||||
should "include appealed posts in the modqueue" do
|
||||
@appeal = create(:post_appeal)
|
||||
get_auth modqueue_index_path, @admin
|
||||
|
||||
Reference in New Issue
Block a user