FIX: Clear anon cache when clearing recently readonly.

This commit is contained in:
Guo Xiang Tan 2019-01-22 09:51:45 +08:00
parent 3359b3baca
commit b0adffdef5
2 changed files with 16 additions and 0 deletions

View File

@ -374,6 +374,8 @@ module Discourse
def self.clear_readonly! def self.clear_readonly!
last_read_only[$redis.namespace] = nil last_read_only[$redis.namespace] = nil
Site.clear_anon_cache!
true
end end
def self.request_refresh!(user_ids: nil) def self.request_refresh!(user_ids: nil)

View File

@ -238,6 +238,20 @@ describe Discourse do
expect(Discourse.last_read_only['default']).to eq(time) expect(Discourse.last_read_only['default']).to eq(time)
end end
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 end
context "#handle_exception" do context "#handle_exception" do