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

FIX: Enabling readonly mode should clear anon cache as well.
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 149b2f5..cd0858f 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -313,6 +313,7 @@ module Discourse
     end
 
     MessageBus.publish(readonly_channel, true)
+    Site.clear_anon_cache!
     true
   end
 
diff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rb
index 068dad3..5263c5f 100644
--- a/spec/components/discourse_spec.rb
+++ b/spec/components/discourse_spec.rb
@@ -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

GitHub
sha: d7660dfe