DEV: Clean up state leak in Site tests.

This commit is contained in:
Alan Guo Xiang Tan 2021-06-25 09:15:17 +08:00
parent 5c3109281d
commit 3b32b6bc13
2 changed files with 7 additions and 4 deletions

View File

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

View File

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