mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 07:45:40 +08:00
DEV: Change default bootstrap min users for private sites (#19810)
* DEV: Change default bootstrap min users for private sites Private sites should have a lower min users to escape bootstrap mode. * reset back to 50 if site is changed to public, added some tests * fix formatting * Remove comment * Move constant declaration * Update config/initializers/014-track-setting-changes.rb Shaving a bit of repetition Co-authored-by: Jarek Radosz <jradosz@gmail.com> * Remove commented out code * stree --------- Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
parent
f4ce402dc4
commit
64986244d7
@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
PRIVATE_BOOTSTRAP_MODE_MIN_USERS = 10
|
||||
|
||||
DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
||||
Category.clear_subcategory_ids if name === :max_category_nesting
|
||||
|
||||
@ -29,6 +31,20 @@ DiscourseEvent.on(:site_setting_changed) do |name, old_value, new_value|
|
||||
end
|
||||
end
|
||||
|
||||
# Set bootstrap min users for private sites to a lower default
|
||||
if name == :login_required && SiteSetting.bootstrap_mode_enabled == true
|
||||
if new_value == true &&
|
||||
SiteSetting.bootstrap_mode_min_users == SiteSetting.defaults.get(:bootstrap_mode_min_users)
|
||||
SiteSetting.bootstrap_mode_min_users = PRIVATE_BOOTSTRAP_MODE_MIN_USERS
|
||||
end
|
||||
|
||||
# Set bootstrap min users for public sites back to the default
|
||||
if new_value == false &&
|
||||
SiteSetting.bootstrap_mode_min_users == PRIVATE_BOOTSTRAP_MODE_MIN_USERS
|
||||
SiteSetting.bootstrap_mode_min_users = SiteSetting.defaults.get(:bootstrap_mode_min_users)
|
||||
end
|
||||
end
|
||||
|
||||
Stylesheet::Manager.clear_color_scheme_cache! if %i[base_font heading_font].include?(name)
|
||||
|
||||
Report.clear_cache(:storage_stats) if %i[backup_location s3_backup_bucket].include?(name)
|
||||
|
@ -178,6 +178,34 @@ RSpec.describe SiteSettingExtension do
|
||||
end
|
||||
end
|
||||
|
||||
describe "DiscourseEvent for login_required changed to true" do
|
||||
before do
|
||||
SiteSetting.login_required = false
|
||||
SiteSetting.bootstrap_mode_min_users = 50
|
||||
SiteSetting.bootstrap_mode_enabled = true
|
||||
end
|
||||
|
||||
it "lowers bootstrap mode min users for private sites" do
|
||||
SiteSetting.login_required = true
|
||||
|
||||
expect(SiteSetting.bootstrap_mode_min_users).to eq(10)
|
||||
end
|
||||
end
|
||||
|
||||
describe "DiscourseEvent for login_required changed to false" do
|
||||
before do
|
||||
SiteSetting.login_required = true
|
||||
SiteSetting.bootstrap_mode_min_users = 50
|
||||
SiteSetting.bootstrap_mode_enabled = true
|
||||
end
|
||||
|
||||
it "resets bootstrap mode min users for public sites" do
|
||||
SiteSetting.login_required = false
|
||||
|
||||
expect(SiteSetting.bootstrap_mode_min_users).to eq(50)
|
||||
end
|
||||
end
|
||||
|
||||
describe "int setting" do
|
||||
before do
|
||||
settings.setting(:test_setting, 77)
|
||||
|
Loading…
x
Reference in New Issue
Block a user