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 2a75656ff2
This commit is contained in:
David Taylor 2023-10-26 20:17:21 +01:00 committed by GitHub
parent 125c19e8f7
commit c304361588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 38 deletions

View File

@ -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