discourse/spec/jobs/enable_bootstrap_mode_spec.rb
Sam Saffron 4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00

42 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe Jobs::EnableBootstrapMode do
context '.execute' do
let(:admin) { Fabricate(:admin) }
before do
SiteSetting.bootstrap_mode_enabled = false
end
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
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
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