mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
FIX: Serialization of staff_writes_only (#26866)
This commit is contained in:
parent
6c6a56139e
commit
f230767722
|
@ -38,8 +38,8 @@ module ReadOnlyMixin
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_or_check_staff_writes_only_mode
|
def get_or_check_staff_writes_only_mode
|
||||||
check_readonly_mode if @readonly_mode.nil?
|
check_readonly_mode if @staff_writes_only_mode.nil?
|
||||||
@readonly_mode
|
@staff_writes_only_mode
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_readonly_header
|
def add_readonly_header
|
||||||
|
|
|
@ -1332,5 +1332,27 @@ RSpec.describe ApplicationController do
|
||||||
expect(JSON.parse(preloaded_json["visiblePlugins"])).to eq([])
|
expect(JSON.parse(preloaded_json["visiblePlugins"])).to eq([])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "readonly serialization" do
|
||||||
|
it "serializes regular readonly mode correctly" do
|
||||||
|
Discourse.enable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)
|
||||||
|
|
||||||
|
get "/latest"
|
||||||
|
expect(JSON.parse(preloaded_json["isReadOnly"])).to eq(true)
|
||||||
|
expect(JSON.parse(preloaded_json["isStaffWritesOnly"])).to eq(false)
|
||||||
|
ensure
|
||||||
|
Discourse.disable_readonly_mode(Discourse::USER_READONLY_MODE_KEY)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "serializes staff readonly mode correctly" do
|
||||||
|
Discourse.enable_readonly_mode(Discourse::STAFF_WRITES_ONLY_MODE_KEY)
|
||||||
|
|
||||||
|
get "/latest"
|
||||||
|
expect(JSON.parse(preloaded_json["isReadOnly"])).to eq(true)
|
||||||
|
expect(JSON.parse(preloaded_json["isStaffWritesOnly"])).to eq(true)
|
||||||
|
ensure
|
||||||
|
Discourse.disable_readonly_mode(Discourse::STAFF_WRITES_ONLY_MODE_KEY)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user