From 7f65f4aabd87780eae371b8d88eccacd723722dd Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 17 Mar 2026 14:43:05 -0400 Subject: [PATCH] Fix card view "M" hotkey using stale user from fragment cache The hidden "Assign to me" button on the card detail view baked Current.user.id into the form action at render time. When served from fragment cache, a stale user ID could be embedded, assigning cards to the wrong person. Switch to card_self_assignment_path which resolves the current user at request time via SelfAssignmentsController, matching the fix already applied to the board view in 2527f073. ref: https://app.fizzy.do/5986089/cards/3722 --- app/views/cards/display/common/_assignees.html.erb | 4 ++-- test/controllers/cards_controller_test.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/cards/display/common/_assignees.html.erb b/app/views/cards/display/common/_assignees.html.erb index 73bddd901..75ebe4611 100644 --- a/app/views/cards/display/common/_assignees.html.erb +++ b/app/views/cards/display/common/_assignees.html.erb @@ -12,8 +12,8 @@ - <% if Current.user && !local_assigns[:preview] %> - <%= button_to "Assign to me", card_assignments_path(card, params: { assignee_id: Current.user.id }), method: :post, data: {controller: "hotkey", action: "keydown.m@document->hotkey#click" }, hidden: true %> + <% unless local_assigns[:preview] %> + <%= button_to "Assign to me", card_self_assignment_path(card), method: :post, data: {controller: "hotkey", action: "keydown.m@document->hotkey#click" }, hidden: true %> <% end %> diff --git a/test/controllers/cards_controller_test.rb b/test/controllers/cards_controller_test.rb index 901a584f9..f582aa9c0 100644 --- a/test/controllers/cards_controller_test.rb +++ b/test/controllers/cards_controller_test.rb @@ -42,6 +42,15 @@ class CardsControllerTest < ActionDispatch::IntegrationTest assert_redirected_to card_draft_path(card) end + test "show renders assign-to-me hotkey using self assignment path" do + card = cards(:logo) + + get card_path(card) + assert_response :success + + assert_select "form[action=?] button[hidden]", card_self_assignment_path(card), text: "Assign to me" + end + test "show renders inline code in title" do card = cards(:logo) card.update_column :title, "Fix the `bug` in production"