From c3043615887493806cf32effdc0a30272f9a8e75 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 26 Oct 2023 20:17:21 +0100 Subject: [PATCH] DEV: Remove spec calling add_to_serializer (#24116) Calling add_to_serializer is an irreversible operation which affects all the following tests in the suite. This lead to other tests failing because they weren't expecting the extra field on the category serializer. Followup to 2a75656ff24ba750b19838e27e559828a3aaf719 --- spec/requests/categories_controller_spec.rb | 38 --------------------- 1 file changed, 38 deletions(-) diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb index a1248e3fe7a..286ca7e585f 100644 --- a/spec/requests/categories_controller_spec.rb +++ b/spec/requests/categories_controller_spec.rb @@ -372,44 +372,6 @@ RSpec.describe CategoriesController do response.parsed_body["category_list"]["categories"].map { |x| x["id"] }, ).not_to include(uncategorized.id) end - - describe "with serialized category custom fields" do - class CategoryPlugin < Plugin::Instance - end - - let!(:plugin) do - plugin = CategoryPlugin.new - plugin.add_to_serializer(:basic_category, :bob) { object.custom_fields["bob"] } - plugin - end - - before { category.upsert_custom_fields("bob" => "marley") } - after { CategoryList.preloaded_category_custom_fields = Set.new } - - context "when custom fields are not preloaded" do - it "increases the query count" do - queries = track_sql_queries { get "/categories.json" } - - expect(response.status).to eq(200) - category = response.parsed_body["category_list"]["categories"][-1] - expect(category["bob"]).to eq("marley") - expect(queries.count).to eq(7) - end - end - - context "when custom fields are preloaded" do - before { CategoryList.preloaded_category_custom_fields << "bob" } - - it "does not increase the query count" do - queries = track_sql_queries { get "/categories.json" } - - expect(response.status).to eq(200) - category = response.parsed_body["category_list"]["categories"][-1] - expect(category["bob"]).to eq("marley") - expect(queries.count).to eq(6) - end - end - end end describe "extensibility event" do