2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 21:27:38 -05:00
|
|
|
RSpec.describe Jobs::DisableBootstrapMode do
|
2016-04-26 12:08:19 -05:00
|
|
|
|
2022-07-27 05:21:10 -05:00
|
|
|
describe '.execute' do
|
2019-05-06 22:12:20 -05:00
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
2016-04-26 12:08:19 -05:00
|
|
|
|
|
|
|
before do
|
|
|
|
SiteSetting.bootstrap_mode_enabled = true
|
2016-05-04 06:05:54 -05:00
|
|
|
SiteSetting.default_trust_level = TrustLevel[1]
|
|
|
|
SiteSetting.default_email_digest_frequency = 1440
|
2016-04-26 12:08:19 -05:00
|
|
|
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(3)
|
|
|
|
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
|
2016-05-04 06:05:54 -05:00
|
|
|
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).twice
|
|
|
|
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
|
2016-04-26 12:08:19 -05:00
|
|
|
it 'successfully turns off bootstrap mode' do
|
|
|
|
SiteSetting.bootstrap_mode_min_users = 5
|
|
|
|
6.times do
|
|
|
|
Fabricate(:user)
|
|
|
|
end
|
|
|
|
StaffActionLogger.any_instance.expects(:log_site_setting_change).times(3)
|
|
|
|
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|