Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit aa0b53f

Browse files
committed
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.
1 parent 7dd33d2 commit aa0b53f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

spec/lib/random_assign_utils_spec.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
FakeAutomation = Struct.new(:id)
88

99
let!(:automation) { FakeAutomation.new(1) }
10+
let(:fake_logger) { FakeLogger.new }
1011

11-
around do |example|
12-
orig_logger = Rails.logger
13-
Rails.logger = FakeLogger.new
14-
example.run
15-
Rails.logger = orig_logger
12+
before do
13+
SiteSetting.assign_enabled = true
14+
Rails.logger.broadcast_to(fake_logger)
1615
end
1716

18-
before { SiteSetting.assign_enabled = true }
17+
after { Rails.logger.stop_broadcasting_to(fake_logger) }
1918

2019
describe ".automation_script!" do
2120
subject(:auto_assign) { described_class.automation_script!(ctx, fields, automation) }

0 commit comments

Comments
 (0)