From 5ae4cbcf88d7a67b02fcf7601e491d1e43f5c7a0 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 15 Oct 2018 11:15:31 +0800 Subject: [PATCH] DEV: Clear `ColorScheme.hex_cache` to avoid leaking state. --- spec/models/color_scheme_color_spec.rb | 4 ++++ spec/models/color_scheme_spec.rb | 4 ++++ spec/models/topic_spec.rb | 9 +++++++-- spec/rails_helper.rb | 1 - 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/spec/models/color_scheme_color_spec.rb b/spec/models/color_scheme_color_spec.rb index 95830f44094..933698255ed 100644 --- a/spec/models/color_scheme_color_spec.rb +++ b/spec/models/color_scheme_color_spec.rb @@ -1,6 +1,10 @@ require 'rails_helper' describe ColorSchemeColor do + after do + ColorScheme.hex_cache.clear + end + def test_invalid_hex(hex) c = described_class.new(hex: hex) expect(c).not_to be_valid diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb index 974f9aae1f2..fcc23866b09 100644 --- a/spec/models/color_scheme_spec.rb +++ b/spec/models/color_scheme_spec.rb @@ -1,8 +1,12 @@ require 'rails_helper' describe ColorScheme do + after do + ColorScheme.hex_cache.clear + end let(:valid_params) { { name: "Best Colors Evar", colors: valid_colors } } + let(:valid_colors) { [ { name: '$primary_background_color', hex: 'FFBB00' }, { name: '$secondary_background_color', hex: '888888' } diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 5e28d0d618a..2e822abd506 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -1040,9 +1040,14 @@ describe Topic do it "resets the topic archetype" do topic.expects(:add_moderator_post) - MessageBus.expects(:publish).with("/site/banner", nil) - topic.remove_banner!(user) + + message = MessageBus.track_publish do + topic.remove_banner!(user) + end.first + expect(topic.archetype).to eq(Archetype.default) + expect(message.channel).to eq("/site/banner") + expect(message.data).to eq(nil) end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 2deb20cf911..2a78230fbed 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -134,7 +134,6 @@ RSpec.configure do |config| unfreeze_time ActionMailer::Base.deliveries.clear - ColorScheme.hex_cache.clear raise if ActiveRecord::Base.connection_pool.stat[:busy] > 1 end