From 015bc3420eee8d88e1109c2a28ba37ef6842142f Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 3 Feb 2026 09:28:08 -0500 Subject: [PATCH] Fix boost button appearing prematurely on draft cards When updating a draft card (e.g., adding a background image), the turbo stream response was using the published card container partial, which includes the reactions/boost button. Draft cards should use the draft container partial which intentionally omits reactions. Fixes https://app.fizzy.do/5986089/cards/3970 --- app/views/cards/update.turbo_stream.erb | 3 ++- test/controllers/cards_controller_test.rb | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/views/cards/update.turbo_stream.erb b/app/views/cards/update.turbo_stream.erb index 76663e2f0..a8d975555 100644 --- a/app/views/cards/update.turbo_stream.erb +++ b/app/views/cards/update.turbo_stream.erb @@ -1,4 +1,5 @@ -<%= turbo_stream.replace dom_id(@card, :card_container), partial: "cards/container", method: :morph, locals: { card: @card.reload } %> +<% container_partial = @card.drafted? ? "cards/drafts/container" : "cards/container" %> +<%= turbo_stream.replace dom_id(@card, :card_container), partial: container_partial, method: :morph, locals: { card: @card.reload } %> <%= turbo_stream.update dom_id(@card, :edit) do %> <%= render "cards/container/content_display", card: @card %> diff --git a/test/controllers/cards_controller_test.rb b/test/controllers/cards_controller_test.rb index dca7d986b..8007657d4 100644 --- a/test/controllers/cards_controller_test.rb +++ b/test/controllers/cards_controller_test.rb @@ -76,6 +76,17 @@ class CardsControllerTest < ActionDispatch::IntegrationTest assert_equal "Something more in-depth", card.description.to_plain_text.strip end + test "update draft card does not render reactions" do + draft = boards(:writebook).cards.create!(creator: users(:kevin), status: :drafted) + + patch card_path(draft), as: :turbo_stream, params: { + card: { image: fixture_file_upload("moon.jpg", "image/jpeg") } + } + assert_response :success + + assert_no_match "reactions", response.body, "Draft card should not show reactions/boost button" + end + test "users can only see cards in boards they have access to" do get card_path(cards(:logo)) assert_response :success