Filter draft cards from public closed column (#2667)

The public closed column was showing draft cards because it queried
`@board.cards.closed` without a `.published` filter. This adds the
missing `.published` scope to match the pattern used elsewhere in the
public controllers.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mike Dalessio
2026-03-05 20:31:41 -05:00
committed by GitHub
parent 8ee2d7d65f
commit e27c0c5fa1
4 changed files with 22 additions and 2 deletions
@@ -1,5 +1,5 @@
class Public::Boards::Columns::ClosedsController < Public::BaseController class Public::Boards::Columns::ClosedsController < Public::BaseController
def show def show
set_page_and_extract_portion_from @board.cards.closed.recently_closed_first set_page_and_extract_portion_from @board.cards.closed.published.recently_closed_first
end end
end end
@@ -5,7 +5,7 @@
<div class="cards__transition-container"> <div class="cards__transition-container">
<header class="cards__header"> <header class="cards__header">
<%= render "boards/show/expander", title: "Done", count: board.cards.closed.count, column_id: "closed-cards" %> <%= render "boards/show/expander", title: "Done", count: board.cards.closed.published.count, column_id: "closed-cards" %>
<%= link_to public_board_columns_closed_url(board.publication.key), class: "cards__maximize-button btn btn--circle txt-x-small borderless", data: { turbo_frame: "_top" } do %> <%= link_to public_board_columns_closed_url(board.publication.key), class: "cards__maximize-button btn btn--circle txt-x-small borderless", data: { turbo_frame: "_top" } do %>
<%= icon_tag "grid", class: "translucent" %> <%= icon_tag "grid", class: "translucent" %>
@@ -9,4 +9,14 @@ class Public::Boards::Columns::ClosedsControllerTest < ActionDispatch::Integrati
get public_board_columns_closed_path(boards(:writebook).publication.key) get public_board_columns_closed_path(boards(:writebook).publication.key)
assert_response :success assert_response :success
end end
test "show excludes draft cards" do
draft_card = cards(:buy_domain)
draft_card.update!(status: :drafted)
Current.set(user: users(:david)) { draft_card.close }
get public_board_columns_closed_path(boards(:writebook).publication.key)
assert_response :success
assert_not_includes response.body, draft_card.title
end
end end
@@ -21,6 +21,16 @@ class Public::BoardsControllerTest < ActionDispatch::IntegrationTest
assert_response :not_found assert_response :not_found
end end
test "show excludes draft cards from closed count" do
draft_card = cards(:buy_domain)
draft_card.update!(status: :drafted)
Current.set(user: users(:david)) { draft_card.close }
get published_board_path(boards(:writebook))
assert_response :success
assert_select ".cards--closed .cards__expander-count", "1"
end
test "show works without authentication" do test "show works without authentication" do
sign_out sign_out
get published_board_path(boards(:writebook)) get published_board_path(boards(:writebook))