mirror of
https://github.com/discourse/discourse.git
synced 2025-02-11 13:55:07 +00:00
FIX: Improve handling of 'PublicExceptions' when bootstrap_error_pages enabled (#26737)
- Fix the readonly mode checking to avoid empty strings being passed (the `check_readonly_mode` before_action will not execute in the case of these re-dispatched exceptions) Partial backport of bca855f2396998943d52545fd9d59dc0d3da3183
This commit is contained in:
parent
1b44077715
commit
6f688be5c1
@ -643,8 +643,8 @@ class ApplicationController < ActionController::Base
|
||||
store_preloaded("customHTML", custom_html_json)
|
||||
store_preloaded("banner", banner_json)
|
||||
store_preloaded("customEmoji", custom_emoji)
|
||||
store_preloaded("isReadOnly", @readonly_mode.to_s)
|
||||
store_preloaded("isStaffWritesOnly", @staff_writes_only_mode.to_s)
|
||||
store_preloaded("isReadOnly", get_or_check_readonly_mode.to_json)
|
||||
store_preloaded("isStaffWritesOnly", get_or_check_staff_writes_only_mode.to_json)
|
||||
store_preloaded("activatedThemes", activated_themes_json)
|
||||
end
|
||||
|
||||
|
@ -32,6 +32,16 @@ module ReadOnlyMixin
|
||||
end
|
||||
end
|
||||
|
||||
def get_or_check_readonly_mode
|
||||
check_readonly_mode if @readonly_mode.nil?
|
||||
@readonly_mode
|
||||
end
|
||||
|
||||
def get_or_check_staff_writes_only_mode
|
||||
check_readonly_mode if @readonly_mode.nil?
|
||||
@readonly_mode
|
||||
end
|
||||
|
||||
def add_readonly_header
|
||||
response.headers["Discourse-Readonly"] = "true" if @readonly_mode
|
||||
end
|
||||
|
19
spec/system/bootstrap_error_pages_spec.rb
Normal file
19
spec/system/bootstrap_error_pages_spec.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "bootstrap_error_pages", type: :system do
|
||||
before { SiteSetting.bootstrap_error_pages = true }
|
||||
|
||||
it "boots ember for non-existent route" do
|
||||
visit "/foobar"
|
||||
expect(page).not_to have_css("body.no-ember")
|
||||
expect(page).to have_css("#site-logo")
|
||||
expect(page).to have_css("div.page-not-found")
|
||||
end
|
||||
|
||||
it "boots ember for non-existent topic" do
|
||||
visit "/t/999999999999"
|
||||
expect(page).not_to have_css("body.no-ember")
|
||||
expect(page).to have_css("#site-logo")
|
||||
expect(page).to have_css("div.page-not-found")
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user