From 79700162fc84bd25f8a456ef720a059804ec0ce9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 11 Apr 2025 17:47:35 +0200 Subject: [PATCH] Use correct stream name comment, :comments makes no sense for a stream for the reactions --- app/controllers/cards/comments/reactions_controller.rb | 4 ++-- app/views/cards/comments/reactions/_reactions.html.erb | 3 ++- test/controllers/cards/comments/reactions_controller_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/cards/comments/reactions_controller.rb b/app/controllers/cards/comments/reactions_controller.rb index 5eee8122f..2d9a55603 100644 --- a/app/controllers/cards/comments/reactions_controller.rb +++ b/app/controllers/cards/comments/reactions_controller.rb @@ -34,11 +34,11 @@ class Cards::Comments::ReactionsController < ApplicationController end def broadcast_create(reaction) - reaction.broadcast_append_to @comment, :comments, + reaction.broadcast_append_to @comment, :reactions, target: "reactions_comment_#{@comment.id}", partial: "cards/comments/reactions/reaction", locals: { comment: @comment } end def broadcast_remove(reaction) - reaction.broadcast_remove_to @comment, :comments + reaction.broadcast_remove_to @comment, :reactions end end diff --git a/app/views/cards/comments/reactions/_reactions.html.erb b/app/views/cards/comments/reactions/_reactions.html.erb index 5c9b9f846..8b86e4db0 100644 --- a/app/views/cards/comments/reactions/_reactions.html.erb +++ b/app/views/cards/comments/reactions/_reactions.html.erb @@ -1,5 +1,6 @@ <%= turbo_frame_tag comment, :reacting do %> - <%= turbo_stream_from comment, :comments %> + <%= turbo_stream_from comment, :reactions %> +
<%= render partial: "cards/comments/reactions/reaction", collection: comment.reactions.ordered, locals: { comment: comment }, cached: true %> diff --git a/test/controllers/cards/comments/reactions_controller_test.rb b/test/controllers/cards/comments/reactions_controller_test.rb index 83f556992..01fc8a3e3 100644 --- a/test/controllers/cards/comments/reactions_controller_test.rb +++ b/test/controllers/cards/comments/reactions_controller_test.rb @@ -7,7 +7,7 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest end test "create" do - assert_turbo_stream_broadcasts [ @comment, :comments ], count: 1 do + assert_turbo_stream_broadcasts [ @comment, :reactions ], count: 1 do assert_difference -> { @comment.reactions.count }, 1 do post card_comment_reactions_url(@comment.card, @comment, format: :turbo_stream), params: { reaction: { content: "Great work!" } } assert_redirected_to card_comment_reactions_url(@comment.card, @comment) @@ -16,7 +16,7 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest end test "destroy" do - assert_turbo_stream_broadcasts [ @comment, :comments ], count: 1 do + assert_turbo_stream_broadcasts [ @comment, :reactions ], count: 1 do assert_difference -> { @comment.reactions.count }, -1 do delete card_comment_reaction_url(@comment.card, @comment, reactions(:kevin), format: :turbo_stream) assert_response :success