Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On the latest Rails, the tests are broken.
Reason
Rails migrated framework log subscribers to structured events via ActiveSupport::EventReporter, making SQL logs debug-only structured events. See PR: Make framework log subscribers consume structured events (https://github.com/rails/rails/pull/55900/files).
What broke
Tests that captured SQL via a StringIO logger and matched SELECT statements no longer saw logs unless EventReporter debug mode was enabled and the subscriber logger was pointed at the StringIO.
Solution
Added
LoggingTestHelperwith:with_pollingto toggleSolidQueue.silence_pollingfor deterministic polling logs.with_active_record_loggerto:ActiveRecord::Base.loggerto the testStringIO.ActiveSupport.event_reporter.debug_modeand redirectActiveSupport::LogSubscriber.loggerto theStringIOusing one-line flip:old_as_ls_logger, ActiveSupport::LogSubscriber.logger = ActiveSupport::LogSubscriber.logger, logger, restoring afterward.