FIX: Enabling readonly mode should clear anon cache as well.

This commit is contained in:
Guo Xiang Tan 2018-12-18 11:56:25 +08:00
parent abbbcb2622
commit d7660dfe40
2 changed files with 7 additions and 12 deletions

View File

@ -313,6 +313,7 @@ module Discourse
end
MessageBus.publish(readonly_channel, true)
Site.clear_anon_cache!
true
end

View File

@ -164,10 +164,15 @@ describe Discourse do
end
def get_readonly_message
message = nil
messages = MessageBus.track_publish do
yield
end
expect(messages.any? { |m| m.channel == Site::SITE_JSON_CHANNEL })
.to eq(true)
messages.find { |m| m.channel == Discourse.readonly_channel }
end
@ -189,18 +194,7 @@ describe Discourse do
describe ".disable_readonly_mode" do
it "removes a key from redis and publish a message through the message bus" do
Discourse.enable_readonly_mode
message = nil
messages = MessageBus.track_publish do
Discourse.disable_readonly_mode
end
expect(messages.any? { |m| m.channel == Site::SITE_JSON_CHANNEL })
.to eq(true)
message = messages.find { |m| m.channel == Discourse.readonly_channel }
message = get_readonly_message { Discourse.disable_readonly_mode }
assert_readonly_mode_disabled(message, readonly_mode_key)
end