Skip to content

Commit

Permalink
DEV: Don’t replace Rails logger in specs
Browse files Browse the repository at this point in the history
Instead of replacing the Rails logger in specs, we can instead use
`#broadcast_to` which has been introduced in Rails 7.
  • Loading branch information
Flink committed Nov 13, 2024
1 parent f76c30d commit 964e44a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spec/lib/random_assign_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
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) }
Expand Down

0 comments on commit 964e44a

Please sign in to comment.