From e27c0c5fa1b720ec039f88cee5fe804d01cc7a3e Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 5 Mar 2026 20:31:41 -0500 Subject: [PATCH] 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 --- .../public/boards/columns/closeds_controller.rb | 2 +- app/views/public/boards/show/_closed.html.erb | 2 +- .../public/boards/columns/closeds_controller_test.rb | 10 ++++++++++ test/controllers/public/boards_controller_test.rb | 10 ++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/public/boards/columns/closeds_controller.rb b/app/controllers/public/boards/columns/closeds_controller.rb index 63ca9de7b..36df35f14 100644 --- a/app/controllers/public/boards/columns/closeds_controller.rb +++ b/app/controllers/public/boards/columns/closeds_controller.rb @@ -1,5 +1,5 @@ class Public::Boards::Columns::ClosedsController < Public::BaseController 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 diff --git a/app/views/public/boards/show/_closed.html.erb b/app/views/public/boards/show/_closed.html.erb index ec75aed00..02fc10761 100644 --- a/app/views/public/boards/show/_closed.html.erb +++ b/app/views/public/boards/show/_closed.html.erb @@ -5,7 +5,7 @@
- <%= 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 %> <%= icon_tag "grid", class: "translucent" %> diff --git a/test/controllers/public/boards/columns/closeds_controller_test.rb b/test/controllers/public/boards/columns/closeds_controller_test.rb index 71e58e08b..13cdf1470 100644 --- a/test/controllers/public/boards/columns/closeds_controller_test.rb +++ b/test/controllers/public/boards/columns/closeds_controller_test.rb @@ -9,4 +9,14 @@ class Public::Boards::Columns::ClosedsControllerTest < ActionDispatch::Integrati get public_board_columns_closed_path(boards(:writebook).publication.key) assert_response :success 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 diff --git a/test/controllers/public/boards_controller_test.rb b/test/controllers/public/boards_controller_test.rb index 510ac7f6a..b5506cce1 100644 --- a/test/controllers/public/boards_controller_test.rb +++ b/test/controllers/public/boards_controller_test.rb @@ -21,6 +21,16 @@ class Public::BoardsControllerTest < ActionDispatch::IntegrationTest assert_response :not_found 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 sign_out get published_board_path(boards(:writebook))