DEV: Fix flaky test (#25935)

Returned results are ordered by ID, but the fabricated category and
private_category IDs are not always generated in the same order. This
caused the expected and actual results to be in different orders.
This commit is contained in:
Bianca Nenciu 2024-02-28 20:32:14 +02:00 committed by GitHub
parent c8133318b8
commit 80cc538e77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 25 deletions

View File

@ -88,32 +88,28 @@ RSpec.describe HashtagsController do
get "/hashtags/by-ids.json", params: { category: [category.id, private_category.id, -1] }
expect(response.status).to eq(200)
expect(response.parsed_body).to eq(
expect(response.parsed_body["category"]).to contain_exactly(
{
"category" => [
{
"relative_url" => category.url,
"text" => category.name,
"description" => nil,
"colors" => [category.color],
"icon" => "folder",
"type" => "category",
"ref" => category.slug,
"slug" => category.slug,
"id" => category.id,
},
{
"relative_url" => private_category.url,
"text" => private_category.name,
"description" => nil,
"colors" => [private_category.color],
"icon" => "folder",
"type" => "category",
"ref" => private_category.slug,
"slug" => private_category.slug,
"id" => private_category.id,
},
],
"relative_url" => category.url,
"text" => category.name,
"description" => nil,
"colors" => [category.color],
"icon" => "folder",
"type" => "category",
"ref" => category.slug,
"slug" => category.slug,
"id" => category.id,
},
{
"relative_url" => private_category.url,
"text" => private_category.name,
"description" => nil,
"colors" => [private_category.color],
"icon" => "folder",
"type" => "category",
"ref" => private_category.slug,
"slug" => private_category.slug,
"id" => private_category.id,
},
)
end