DEV: Don’t replace Rails logger in specs

Instead of replacing the Rails logger in specs, we can instead use
`#broadcast_to` which has been introduced in Rails 7.
This commit is contained in:
Loïc Guitaut 2024-11-12 17:34:41 +01:00 committed by Loïc Guitaut
parent f76c30dbb7
commit 964e44a63e
1 changed files with 5 additions and 6 deletions

View File

@ -7,15 +7,14 @@ RSpec.describe RandomAssignUtils do
FakeAutomation = Struct.new(:id)
let!(:automation) { FakeAutomation.new(1) }
let(:fake_logger) { FakeLogger.new }
around do |example|
orig_logger = Rails.logger
Rails.logger = FakeLogger.new
example.run
Rails.logger = orig_logger
before do
SiteSetting.assign_enabled = true
Rails.logger.broadcast_to(fake_logger)
end
before { SiteSetting.assign_enabled = true }
after { Rails.logger.stop_broadcasting_to(fake_logger) }
describe ".automation_script!" do
subject(:auto_assign) { described_class.automation_script!(ctx, fields, automation) }