From 4e9773f9f58547cf73580f2bde4fe98550cab0e8 Mon Sep 17 00:00:00 2001 From: Kevin McConnell Date: Tue, 17 Feb 2026 17:05:14 +0000 Subject: [PATCH] Correct card URL in comment JSON output When rendering details of a comment, we were using the card's `id` as the param for the URL. But card routes use the card's number, not ID. --- app/views/cards/comments/_comment.json.jbuilder | 6 +++--- test/controllers/cards/comments_controller_test.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/cards/comments/_comment.json.jbuilder b/app/views/cards/comments/_comment.json.jbuilder index eaf1805d6..58e2f6290 100644 --- a/app/views/cards/comments/_comment.json.jbuilder +++ b/app/views/cards/comments/_comment.json.jbuilder @@ -13,9 +13,9 @@ json.cache! comment do json.card do json.id comment.card_id - json.url card_url(comment.card_id) + json.url card_url(comment.card) end - json.reactions_url card_comment_reactions_url(comment.card_id, comment.id) - json.url card_comment_url(comment.card_id, comment.id) + json.reactions_url card_comment_reactions_url(comment.card, comment) + json.url card_comment_url(comment.card, comment) end diff --git a/test/controllers/cards/comments_controller_test.rb b/test/controllers/cards/comments_controller_test.rb index 26761d22e..a6e83cbef 100644 --- a/test/controllers/cards/comments_controller_test.rb +++ b/test/controllers/cards/comments_controller_test.rb @@ -78,9 +78,9 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_equal comment.id, @response.parsed_body["id"] assert_equal comment.card.id, @response.parsed_body.dig("card", "id") - assert_equal card_url(comment.card.id), @response.parsed_body.dig("card", "url") - assert_equal card_comment_reactions_url(comment.card_id, comment.id), @response.parsed_body["reactions_url"] - assert_equal card_comment_url(comment.card_id, comment.id), @response.parsed_body["url"] + assert_equal card_url(comment.card), @response.parsed_body.dig("card", "url") + assert_equal card_comment_reactions_url(comment.card, comment), @response.parsed_body["reactions_url"] + assert_equal card_comment_url(comment.card, comment), @response.parsed_body["url"] end test "update as JSON" do