mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
6e161d3e75
The most common thing that we do with fab! is: fab!(:thing) { Fabricate(:thing) } This commit adds a shorthand for this which is just simply: fab!(:thing) i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
40 lines
1.4 KiB
Ruby
40 lines
1.4 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
|
|
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
|
|
|
|
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
|
|
|
|
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(3)
|
|
Jobs::DisableBootstrapMode.new.execute(user_id: admin.id)
|
|
end
|
|
end
|
|
end
|