Skip to content

Commit 0eb3c03

Browse files
authored
Fix debouncer tests to wait on correct debouncer (#767)
The wait for the first debouncer meant that calling `refresh_debouncer_for` for the second one could create a new debouncer rather than returning the existing one.
1 parent 89c363e commit 0eb3c03

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

test/streams/streams_channel_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Turbo::StreamsChannelTest < ActionCable::Channel::TestCase
8787
assert_broadcast_on "stream", turbo_stream_refresh_tag(request_id: "123") do
8888
Turbo::StreamsChannel.broadcast_refresh_to "stream"
8989
end
90-
90+
9191
assert_broadcast_on "stream", turbo_stream_refresh_tag(request_id: "456", refresh: "morph") do
9292
Turbo::StreamsChannel.broadcast_refresh_to "stream", request_id: "456", refresh: "morph"
9393
end
@@ -229,8 +229,10 @@ class Turbo::StreamsChannelTest < ActionCable::Channel::TestCase
229229
Turbo.current_request_id = "456"
230230
3.times { Turbo::StreamsChannel.broadcast_refresh_later_to "stream" }
231231

232-
Turbo::StreamsChannel.refresh_debouncer_for("stream", request_id: "123").wait
233-
Turbo::StreamsChannel.refresh_debouncer_for("stream", request_id: "456").wait
232+
debouncer_123 = Turbo::StreamsChannel.refresh_debouncer_for("stream", request_id: "123")
233+
debouncer_456 = Turbo::StreamsChannel.refresh_debouncer_for("stream", request_id: "456")
234+
debouncer_123.wait
235+
debouncer_456.wait
234236
end
235237
end
236238
end

test/test_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def with_production_debouncer(&block)
2929
sleep Turbo::Debouncer::DEFAULT_DELAY + 0.2
3030

3131
turbo_keys = Thread.current.keys.select { |k| k.to_s.start_with?("turbo-") }
32-
assert_empty turbo_keys, "Thread-locals were not cleaned up" if RUBY_VERSION >= "3.3"
32+
assert_empty turbo_keys, "Thread-locals were not cleaned up"
3333
end
3434
end
3535

0 commit comments

Comments
 (0)