Manage comments with streams

We replacing the full list of comments within a turbo frame, which didn't feel great when you had several comments.
This commit is contained in:
Jorge Manrubia
2025-11-13 17:00:19 +01:00
parent bddbc0c0ac
commit 17876b30d4
9 changed files with 17 additions and 9 deletions
@@ -7,14 +7,14 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest
test "create" do
assert_difference -> { cards(:logo).comments.count }, +1 do
post card_comments_path(cards(:logo), params: { comment: { body: "Agreed." } })
post card_comments_path(cards(:logo)), params: { comment: { body: "Agreed." } }, as: :turbo_stream
end
assert_response :success
end
test "update" do
put card_comment_path(cards(:logo), comments(:logo_agreement_kevin)), params: { comment: { body: "I've changed my mind" } }
put card_comment_path(cards(:logo), comments(:logo_agreement_kevin)), params: { comment: { body: "I've changed my mind" } }, as: :turbo_stream
assert_response :success
assert_action_text "I've changed my mind", comments(:logo_agreement_kevin).reload.body
@@ -22,7 +22,7 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest
test "update another user's comment" do
assert_no_changes -> { comments(:logo_agreement_jz).reload.body.to_s } do
put card_comment_path(cards(:logo), comments(:logo_agreement_jz)), params: { comment: { body: "I've changed my mind" } }
put card_comment_path(cards(:logo), comments(:logo_agreement_jz)), params: { comment: { body: "I've changed my mind" } }, as: :turbo_stream
end
assert_response :forbidden