DEV: Fix flaky category hashtag spec (#19397)

This sometimes got the Uncategorized category and
sometimes not, because it also had a topic count
of 0 same as the "fun" category. Giving the "fun"
category a higher count will fix the issue.
This commit is contained in:
Martin Brennan 2022-12-09 11:31:32 +10:00 committed by GitHub
parent f449113c8b
commit 138dac9257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe CategoryHashtagDataSource do
fab!(:parent_category) { Fabricate(:category, slug: "fun") }
fab!(:parent_category) { Fabricate(:category, slug: "fun", topic_count: 2) }
fab!(:category1) do
Fabricate(:category, slug: "random", topic_count: 12, parent_category: parent_category)
end
@ -71,7 +71,7 @@ RSpec.describe CategoryHashtagDataSource do
describe "#search_without_term" do
it "returns distinct categories ordered by topic_count" do
expect(described_class.search_without_term(guardian, 5).map(&:slug)).to eq(
["books", "movies", "casual", "random", "#{uncategorized_category.slug}"],
["books", "movies", "casual", "random", "fun"],
)
end