FIX: Updating presence status in readonly mode should fail gracefully (#24333)
This commit is contained in:
parent
bed4b3ee91
commit
e845138bc1
12
.rubocop.yml
12
.rubocop.yml
|
@ -11,3 +11,15 @@ Discourse/NoResetColumnInformationInMigrations:
|
|||
Lint/Debugger:
|
||||
Exclude:
|
||||
- script/**/*
|
||||
|
||||
RSpec/ContextWording:
|
||||
Prefixes:
|
||||
- when
|
||||
- with
|
||||
- without
|
||||
- for
|
||||
- while
|
||||
- if
|
||||
- as
|
||||
- after
|
||||
- in
|
||||
|
|
|
@ -42,6 +42,8 @@ class PresenceController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
raise Discourse::ReadOnly if @readonly_mode
|
||||
|
||||
client_id = params[:client_id]
|
||||
if !client_id.is_a?(String) || client_id.blank?
|
||||
raise Discourse::InvalidParameters.new(:client_id)
|
||||
|
|
|
@ -44,6 +44,25 @@ RSpec.describe PresenceController do
|
|||
end
|
||||
|
||||
describe "#update" do
|
||||
context "in readonly mode" do
|
||||
use_redis_snapshotting
|
||||
|
||||
before { Discourse.enable_readonly_mode }
|
||||
|
||||
it "produces 503" do
|
||||
sign_in(user)
|
||||
client_id = SecureRandom.hex
|
||||
|
||||
post "/presence/update.json",
|
||||
params: {
|
||||
client_id: client_id,
|
||||
present_channels: [ch1.name, ch2.name],
|
||||
}
|
||||
|
||||
expect(response.status).to eq(503)
|
||||
end
|
||||
end
|
||||
|
||||
it "works" do
|
||||
sign_in(user)
|
||||
client_id = SecureRandom.hex
|
||||
|
|
Loading…
Reference in New Issue