Skip to content

Commit 2df96a0

Browse files
committed
Fix flaky InstrumentationTest
1 parent 3a98b47 commit 2df96a0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/cases/coerced_tests.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,25 @@ class BindParameterTest < ActiveRecord::TestCase
151151
end
152152

153153

154-
154+
module ActiveRecord
155+
class InstrumentationTest < ActiveRecord::TestCase
156+
# This fails randomly due to schema cache being lost?
157+
coerce_tests! :test_payload_name_on_load
158+
def test_payload_name_on_load_coerced
159+
Book.create(name: "test book")
160+
Book.first
161+
subscriber = ActiveSupport::Notifications.subscribe("sql.active_record") do |*args|
162+
event = ActiveSupport::Notifications::Event.new(*args)
163+
if event.payload[:sql].match "SELECT"
164+
assert_equal "Book Load", event.payload[:name]
165+
end
166+
end
167+
Book.first
168+
ensure
169+
ActiveSupport::Notifications.unsubscribe(subscriber) if subscriber
170+
end
171+
end
172+
end
155173

156174
class CalculationsTest < ActiveRecord::TestCase
157175
# This fails randomly due to schema cache being lost?

0 commit comments

Comments
 (0)