DEV: Clean up state leak in `Site` tests.

DEV: Clean up state leak in Site tests.

diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb
index 8ea6e9b..3e2e0c2 100644
--- a/spec/models/site_spec.rb
+++ b/spec/models/site_spec.rb
@@ -3,6 +3,9 @@
 require 'rails_helper'
 
 describe Site do
+  after do
+    Site.clear_cache
+  end
 
   def expect_correct_themes(guardian)
     json = Site.json_for(guardian)
@@ -63,10 +66,6 @@ describe Site do
     fab!(:user) { Fabricate(:user) }
     fab!(:guardian) { Guardian.new(user) }
 
-    after do
-      Site.clear_cache
-    end
-
     it "omits read restricted categories" do
       expect(Site.new(guardian).categories.map(&:id)).to contain_exactly(
         SiteSetting.uncategorized_category_id, category.id
@@ -136,6 +135,8 @@ describe Site do
       categories = Site.new(Guardian.new).categories
 
       expect(categories.last[:custom_fields]["enable_marketplace"]).to eq('f')
+    ensure
+      Site.preloaded_category_custom_fields.clear
     end
   end
 
diff --git a/spec/serializers/site_serializer_spec.rb b/spec/serializers/site_serializer_spec.rb
index 482905d..8dca84a 100644
--- a/spec/serializers/site_serializer_spec.rb
+++ b/spec/serializers/site_serializer_spec.rb
@@ -26,6 +26,8 @@ describe SiteSerializer do
     c1 = serialized[:categories].find { |c| c[:id] == category.id }
 
     expect(c1[:custom_fields]["enable_marketplace"]).to eq("t")
+  ensure
+    Site.preloaded_category_custom_fields.clear
   end
 
   it "includes category tags" do

GitHub sha: 3b32b6bc136d69bcfa94fafd0cf1d3fb7d9146dc

This commit appears in #13522 which was approved by martin. It was merged by tgxworld.