From b0adffdef56d571942bd07d8977c160862ec49da Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 22 Jan 2019 09:51:45 +0800 Subject: [PATCH] FIX: Clear anon cache when clearing recently readonly. --- lib/discourse.rb | 2 ++ spec/components/discourse_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/discourse.rb b/lib/discourse.rb index bc382d71626..c8d76f3e158 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -374,6 +374,8 @@ module Discourse def self.clear_readonly! last_read_only[$redis.namespace] = nil + Site.clear_anon_cache! + true end def self.request_refresh!(user_ids: nil) diff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rb index 5263c5f1a9e..058b61b7b1e 100644 --- a/spec/components/discourse_spec.rb +++ b/spec/components/discourse_spec.rb @@ -238,6 +238,20 @@ describe Discourse do expect(Discourse.last_read_only['default']).to eq(time) end end + + describe ".clear_readonly!" do + it "publishes the right message" do + Discourse.received_readonly! + messages = [] + + expect do + messages = MessageBus.track_publish { Discourse.clear_readonly! } + end.to change { Discourse.last_read_only['default'] }.to(nil) + + expect(messages.any? { |m| m.channel == Site::SITE_JSON_CHANNEL }) + .to eq(true) + end + end end context "#handle_exception" do