DEV: Don’t replace Rails logger in specs (#29721)

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-13 01:47:39 +01:00
committed by GitHub
parent 907fbd6f1e
commit d637bd6519
17 changed files with 113 additions and 127 deletions

View File

@@ -967,12 +967,12 @@ ensure
end
def track_log_messages
old_logger = Rails.logger
logger = Rails.logger = FakeLogger.new
logger = FakeLogger.new
Rails.logger.broadcast_to(logger)
yield logger
logger
ensure
Rails.logger = old_logger
Rails.logger.stop_broadcasting_to(logger)
end
# this takes a string and returns a copy where 2 different