discourse/spec/jobs/disable_bootstrap_mode_spec.rb
Vinoth Kannan 9d88f80f26
UX: make first admin a moderator to review user approvals. (#26588)
Previously, when the new site was created and after the first admin login, no one will receive notifications to review the user approval queue since only the moderators would receive the PMs about it. Also, this PR will change the "pending_users_reminder_delay_minutes" site setting to 5 minutes while the site is in bootstrap mode.
2024-04-10 20:59:03 +05:30

41 lines
1.5 KiB
Ruby

# frozen_string_literal: true
RSpec.describe Jobs::DisableBootstrapMode do
describe ".execute" do
fab!(:admin)
before do
SiteSetting.bootstrap_mode_enabled = true
SiteSetting.default_trust_level = TrustLevel[1]
SiteSetting.default_email_digest_frequency = 1440
SiteSetting.pending_users_reminder_delay_minutes = 5
end
it "does not execute if bootstrap mode is already disabled" do
SiteSetting.bootstrap_mode_enabled = false
StaffActionLogger.any_instance.expects(:log_site_setting_change).never
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
end
it "turns off bootstrap mode if bootstrap_mode_min_users is set to 0" do
SiteSetting.bootstrap_mode_min_users = 0
StaffActionLogger.any_instance.expects(:log_site_setting_change).times(4)
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
end
it "does not amend setting that is not in bootstrap state" do
SiteSetting.bootstrap_mode_min_users = 0
SiteSetting.default_trust_level = TrustLevel[3]
StaffActionLogger.any_instance.expects(:log_site_setting_change).times(3)
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
end
it "successfully turns off bootstrap mode" do
SiteSetting.bootstrap_mode_min_users = 5
6.times { Fabricate(:user) }
StaffActionLogger.any_instance.expects(:log_site_setting_change).times(4)
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
end
end
end