2019-05-03 06:21:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe ForumsController do
|
|
|
|
|
|
|
|
describe "read only header" do
|
|
|
|
it "returns no read only header by default" do
|
|
|
|
get "/srv/status"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
expect(response.headers['Discourse-Readonly']).to eq(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a readonly header if the site is read only" do
|
2019-06-21 10:08:57 -04:00
|
|
|
Discourse.received_postgres_readonly!
|
2019-05-03 06:21:07 -04:00
|
|
|
get "/srv/status"
|
|
|
|
expect(response.status).to eq(200)
|
2022-05-17 14:06:08 -04:00
|
|
|
expect(response.headers['Discourse-Readonly']).to eq('true')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a readonly header if the site is in staff-writes-only mode" do
|
|
|
|
Discourse.stubs(:staff_writes_only_mode?).returns(true)
|
|
|
|
get "/srv/status"
|
|
|
|
expect(response.status).to eq(200)
|
2019-05-03 06:21:07 -04:00
|
|
|
expect(response.headers['Discourse-Readonly']).to eq('true')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-15 00:41:59 -04:00
|
|
|
describe "cluster parameter" do
|
|
|
|
it "returns a 500 response if the cluster is not configured" do
|
|
|
|
get "/srv/status?cluster=abc"
|
|
|
|
expect(response.status).to eq(500)
|
|
|
|
expect(response.body).to include("not configured")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a 500 response if the cluster does not match" do
|
|
|
|
global_setting(:cluster_name, "mycluster")
|
|
|
|
get "/srv/status?cluster=abc"
|
|
|
|
expect(response.status).to eq(500)
|
|
|
|
expect(response.body).to include("not match")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a 200 response if the cluster does match" do
|
|
|
|
global_setting(:cluster_name, "mycluster")
|
|
|
|
get "/srv/status?cluster=abc"
|
|
|
|
expect(response.status).to eq(500)
|
|
|
|
expect(response.body).to include("not match")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns a 200 response when given shutdown_ok" do
|
|
|
|
get "/srv/status?shutdown_ok=1"
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-03 06:21:07 -04:00
|
|
|
end
|