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
This commit is contained in:
Mike Dalessio
2026-02-03 09:28:08 -05:00
parent 636b109dba
commit 015bc3420e
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -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 %>
+11
View File
@@ -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