File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -187,11 +187,19 @@ class ActiveRecordTest < Minitest::Test
187187 }
188188 )
189189 end
190+ end
190191
191- it "marks async queries with async: true" do
192+ describe "async queries" do
193+ before do
192194 skip "Not applicable to older rails" if Rails . version . to_f < 7.1
193- skip "TODO: Fails on Rails 8 because of a missing session." if Rails . version . to_i >= 8
195+ ActiveRecord ::Base . asynchronous_queries_tracker . start_session
196+ end
194197
198+ after do
199+ ActiveRecord ::Base . asynchronous_queries_tracker . finalize_session
200+ end
201+
202+ it "marks async queries with async: true" do
195203 expected_sql = 'SELECT COUNT(*) FROM "samples"'
196204
197205 messages = semantic_logger_events do
@@ -209,6 +217,10 @@ class ActiveRecordTest < Minitest::Test
209217 payload_includes : { sql : expected_sql }
210218 )
211219 end
220+
221+ # On Rails prior to 8.0.2, these assertions will mostly pass, but not always.
222+ # https://github.com/rails/rails/pull/54344
223+ skip "Older Rails has flakey async instrumentation" if Rails . version < Gem ::Version . new ( "8.0.2" )
212224 refute messages [ 0 ] . payload . key? ( :async )
213225 assert_equal true , messages [ 1 ] . payload [ :async ]
214226 end
You can’t perform that action at this time.
0 commit comments