From 2bce18358155f2cb3ad0f69a7779c3c911fa0ed4 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 25 Aug 2016 23:30:41 +0800 Subject: [PATCH] FIX: User enabled readonly mode was not working. --- lib/discourse.rb | 2 +- spec/components/discourse_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/discourse.rb b/lib/discourse.rb index 73495c9e7ac..c0be4dea179 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -235,7 +235,7 @@ module Discourse end def self.readonly_mode? - recently_readonly? || !!$redis.get(READONLY_MODE_KEY) + recently_readonly? || !!$redis.get(READONLY_MODE_KEY) || !!$redis.get(USER_READONLY_MODE_KEY) end def self.request_refresh! diff --git a/spec/components/discourse_spec.rb b/spec/components/discourse_spec.rb index e713b997052..5d441eacc33 100644 --- a/spec/components/discourse_spec.rb +++ b/spec/components/discourse_spec.rb @@ -158,6 +158,14 @@ describe Discourse do Discourse.received_readonly! expect(Discourse.readonly_mode?).to eq(true) end + + it "returns true when user enabled readonly mode key is present in redis" do + Discourse.enable_readonly_mode(user_enabled: true) + expect(Discourse.readonly_mode?).to eq(true) + + Discourse.disable_readonly_mode(user_enabled: true) + expect(Discourse.readonly_mode?).to eq(false) + end end describe ".received_readonly!" do