Skip to content

Commit 19152c1

Browse files
committed
Add workaround for ActiveRecord logger
1 parent 6e3b745 commit 19152c1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

spec/integration/rails/spec_helper.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ def with_active_record_log(colorize: true)
2222
io = StringIO.new
2323
prev_logger = ActiveRecord::Base.logger
2424
ActiveRecord::Base.logger = Logger.new(io)
25-
yield
25+
# Work aroudn .logger = ... issue on Rails main
26+
# https://github.com/rails/rails/issues/56230
27+
if ActiveSupport.respond_to?(:event_reporter)
28+
ActiveSupport.event_reporter.with_debug do
29+
yield
30+
end
31+
else
32+
yield
33+
end
2634
str = io.string
2735
if !colorize
2836
str.gsub!(/\e\[([;\d]+)?m/, '')

0 commit comments

Comments
 (0)