From 4c667f16c77cff0807ff49f82811aeb86d2c7b20 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 21 Mar 2024 10:49:13 +0800 Subject: [PATCH] DEV: Fix state leak in test causing flaky tests (#26282) Why this change? The test registers a category custom field to preload but doesn't remove it at the end of the test causing a state leak which can result in other tests failing. --- spec/requests/categories_controller_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb index 076045fea7f..d8948831207 100644 --- a/spec/requests/categories_controller_spec.rb +++ b/spec/requests/categories_controller_spec.rb @@ -1166,6 +1166,8 @@ RSpec.describe CategoriesController do expect(response.parsed_body["categories"].length).to eq(1) expect(response.parsed_body["categories"][0]["custom_fields"]).to eq("bob" => "marley") + ensure + Site.reset_preloaded_category_custom_fields end context "without include_ancestors" do