From 822c3bb2ad00822cbb024555169a2367085c3319 Mon Sep 17 00:00:00 2001 From: "Stanko K.R." Date: Wed, 24 Dec 2025 08:45:31 +0100 Subject: [PATCH 1/2] Expose the card ID and URL on comments --- app/views/cards/comments/_comment.json.jbuilder | 5 +++++ test/controllers/cards/comments_controller_test.rb | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/views/cards/comments/_comment.json.jbuilder b/app/views/cards/comments/_comment.json.jbuilder index 3eb9855ed..eaf1805d6 100644 --- a/app/views/cards/comments/_comment.json.jbuilder +++ b/app/views/cards/comments/_comment.json.jbuilder @@ -11,6 +11,11 @@ json.cache! comment do json.creator comment.creator, partial: "users/user", as: :user + json.card do + json.id comment.card_id + json.url card_url(comment.card_id) + end + json.reactions_url card_comment_reactions_url(comment.card_id, comment.id) json.url card_comment_url(comment.card_id, comment.id) end diff --git a/test/controllers/cards/comments_controller_test.rb b/test/controllers/cards/comments_controller_test.rb index b34b64193..ef6dbf6e2 100644 --- a/test/controllers/cards/comments_controller_test.rb +++ b/test/controllers/cards/comments_controller_test.rb @@ -63,10 +63,12 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest test "show as JSON" do comment = comments(:logo_agreement_kevin) - get card_comment_path(cards(:logo), comment), as: :json + get card_comment_path(comment.card, comment), as: :json 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") end test "update as JSON" do From 21fa6ba4588192e7754a7aad8c43feb326088eb9 Mon Sep 17 00:00:00 2001 From: "Stanko K.R." Date: Wed, 24 Dec 2025 08:47:38 +0100 Subject: [PATCH 2/2] Update documentation --- docs/API.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/API.md b/docs/API.md index 3c1d91977..ee1820f28 100644 --- a/docs/API.md +++ b/docs/API.md @@ -796,6 +796,10 @@ __Response:__ "created_at": "2025-12-05T19:36:35.401Z", "url": "http://fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7" }, + "card": { + "id": "03f5v9zo9qlcwwpyc0ascnikz", + "url": "http://fizzy.localhost:3006/897362094/cards/03f5v9zo9qlcwwpyc0ascnikz" + }, "reactions_url": "http://fizzy.localhost:3006/897362094/cards/3/comments/03f5v9zo9qlcwwpyc0ascnikz/reactions", "url": "http://fizzy.localhost:3006/897362094/cards/3/comments/03f5v9zo9qlcwwpyc0ascnikz" } @@ -826,6 +830,10 @@ __Response:__ "created_at": "2025-12-05T19:36:35.401Z", "url": "http://fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7" }, + "card": { + "id": "03f5v9zo9qlcwwpyc0ascnikz", + "url": "http://fizzy.localhost:3006/897362094/cards/03f5v9zo9qlcwwpyc0ascnikz" + }, "reactions_url": "http://fizzy.localhost:3006/897362094/cards/3/comments/03f5v9zo9qlcwwpyc0ascnikz/reactions", "url": "http://fizzy.localhost:3006/897362094/cards/3/comments/03f5v9zo9qlcwwpyc0ascnikz" }