DEV: Fix flaky test due to a lack of deterministic ordering (#20087)

This commit is contained in:
Alan Guo Xiang Tan 2023-01-31 08:57:34 +08:00 committed by GitHub
parent 6934edd97c
commit c5c72a74b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -63,10 +63,13 @@ class TagsController < ::ApplicationController
unrestricted_tags = DiscourseTagging.filter_visible(tags.where(target_tag_id: nil), guardian)
categories =
Category.where(
Category
.where(
"id IN (SELECT category_id FROM category_tags WHERE category_id IN (?))",
guardian.allowed_category_ids,
).includes(:none_synonym_tags)
)
.includes(:none_synonym_tags)
.order(:id)
category_tag_counts =
categories

View File

@ -197,7 +197,7 @@ RSpec.describe TagsController do
expect(categories[0]["tags"][0]["target_tag"]).to eq(nil)
end
xit "does not result in N+1 queries when there are multiple categories configured with tags for an admin user" do
it "does not result in N+1 queries when there are multiple categories configured with tags for an admin user" do
category.update!(tags: [test_tag])
sign_in(admin)