Skip to content

Commit 2566083

Browse files
committed
Address ActiveRecord::InstrumentationTest#test_payload_connection_with_query_cache_enabled failure
This commit addresses `ActiveRecord::InstrumentationTest#test_payload_connection_with_query_cache_enabled` failure with `postgresql` adapter because it executes `SHOW search_path` adds another notification that is executed via `sql_key`. This statements is not executed by other database adapters. - Failures fixed by this commit ```ruby $ ARCONN=postgresql bin/test test/cases/instrumentation_test.rb -n test_payload_connection_with_query_cache_enabled Using postgresql Run options: -n test_payload_connection_with_query_cache_enabled --seed 65179 F Failure: ActiveRecord::InstrumentationTest#test_payload_connection_with_query_cache_enabled [test/cases/instrumentation_test.rb:142]: Expected 2 instead of 3 notifications for sql.active_record. Expected: 2 Actual: 3 bin/test test/cases/instrumentation_test.rb:138 Finished in 0.029114s, 34.3482 runs/s, 34.3482 assertions/s. 1 runs, 1 assertions, 1 failures, 0 errors, 0 skips $ ``` Fix rails#53858 Related to rails#53822
1 parent cd8ecdb commit 2566083

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

activerecord/test/cases/instrumentation_test.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,16 @@ def test_payload_connection_with_query_cache_disabled
138138
def test_payload_connection_with_query_cache_enabled
139139
connection = ClothingItem.lease_connection
140140

141-
payloads = capture_notifications("sql.active_record") do
142-
assert_notifications_count("sql.active_record", 2) do
143-
Book.cache do
144-
Book.first
145-
Book.first
146-
end
141+
notifications = capture_notifications("sql.active_record") do
142+
Book.cache do
143+
Book.first
144+
Book.first
147145
end
148-
end.map(&:payload)
146+
end
147+
148+
payloads = notifications.select { _1.payload[:sql].match?("SELECT") }.map(&:payload)
149149

150+
assert_equal 2, payloads.size
150151
assert_equal connection, payloads.first[:connection]
151152
assert_equal connection, payloads.second[:connection]
152153
end

0 commit comments

Comments
 (0)