mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-08-14 11:00:43 +09:00
df76a227dc
First open source release of Campfire 🎉
18 lines
654 B
Ruby
18 lines
654 B
Ruby
module TurboTestHelper
|
|
def assert_rendered_turbo_stream_broadcast(*streambles, action:, target:, &block)
|
|
streams = find_broadcasts_for(*streambles)
|
|
target = ActionView::RecordIdentifier.dom_id(*target)
|
|
assert_select Nokogiri::HTML.fragment(streams), %(turbo-stream[action="#{action}"][target="#{target}"]), &block
|
|
end
|
|
|
|
private
|
|
def find_broadcasts_for(*streambles)
|
|
broadcasting = streambles.collect do |streamble|
|
|
streamble.try(:to_gid_param) || streamble
|
|
end.join(":")
|
|
|
|
broadcasts = ActionCable.server.pubsub.broadcasts(broadcasting)
|
|
broadcasts.collect { |b| JSON.parse(b) }.join("\n\n")
|
|
end
|
|
end
|