@@ -236,6 +236,36 @@ class Turbo::StreamsChannelTest < ActionCable::Channel::TestCase
236236 end
237237 end
238238
239+ test "broadcasting action later with ActiveModel array target" do
240+ options = { partial : "messages/message" , locals : { message : "hello!" } }
241+
242+ message = Message . new ( id : 42 )
243+ target = [ message , "opt" ]
244+ expected_target = "opt_message_42"
245+
246+ assert_broadcast_on "stream" , turbo_stream_action_tag ( "prepend" , target : expected_target , template : render ( options ) ) do
247+ perform_enqueued_jobs do
248+ Turbo ::StreamsChannel . broadcast_action_later_to \
249+ "stream" , action : "prepend" , target : target , **options
250+ end
251+ end
252+ end
253+
254+ test "broadcasting action later with multiple ActiveModel targets" do
255+ options = { partial : "messages/message" , locals : { message : "hello!" } }
256+
257+ one = Message . new ( id : 1 )
258+ targets = [ one , "messages" ]
259+ expected_targets = "#messages_message_1"
260+
261+ assert_broadcast_on "stream" , turbo_stream_action_tag ( "prepend" , targets : expected_targets , template : render ( options ) ) do
262+ perform_enqueued_jobs do
263+ Turbo ::StreamsChannel . broadcast_action_later_to \
264+ "stream" , action : "prepend" , targets : targets , **options
265+ end
266+ end
267+ end
268+
239269 test "broadcasting render now" do
240270 assert_broadcast_on "stream" , turbo_stream_action_tag ( "replace" , target : "message_1" , template : "Goodbye!" ) do
241271 Turbo ::StreamsChannel . broadcast_render_to "stream" , partial : "messages/message"
0 commit comments