2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Jobs::EnableBootstrapMode do
|
2022-07-27 06:21:10 -04:00
|
|
|
describe ".execute" do
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
2016-04-26 13:08:19 -04:00
|
|
|
|
|
|
|
before { SiteSetting.bootstrap_mode_enabled = false }
|
|
|
|
|
|
|
|
it "raises an error when user_id is missing" do
|
|
|
|
expect { Jobs::EnableBootstrapMode.new.execute({}) }.to raise_error(
|
|
|
|
Discourse::InvalidParameters,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not execute if bootstrap mode is already enabled" do
|
|
|
|
SiteSetting.bootstrap_mode_enabled = true
|
|
|
|
StaffActionLogger.any_instance.expects(:log_site_setting_change).never
|
|
|
|
Jobs::EnableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not turn on bootstrap mode if first admin already exists" do
|
|
|
|
first_admin = Fabricate(:admin)
|
|
|
|
StaffActionLogger.any_instance.expects(:log_site_setting_change).never
|
|
|
|
Jobs::EnableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
|
2016-05-04 07:05:54 -04:00
|
|
|
it "does not amend setting that is not in default state" do
|
|
|
|
SiteSetting.default_trust_level = TrustLevel[3]
|
|
|
|
StaffActionLogger.any_instance.expects(:log_site_setting_change).twice
|
|
|
|
Jobs::EnableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
|
2016-04-26 13:08:19 -04:00
|
|
|
it "successfully turns on bootstrap mode" do
|
|
|
|
StaffActionLogger.any_instance.expects(:log_site_setting_change).times(3)
|
|
|
|
Jobs::EnableBootstrapMode.new.execute(user_id: admin.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|