Skip to content

Commit 49eb3ae

Browse files
authored
Return the moved card on PUT /:account_slug/cards/:card_number/board (#2849)
The JSON response was `204 No Content`, which forced clients to make a follow-up GET to see the card on its new board. The Smithy contract the SDKs are generated from already declares `MoveCard` returns a Card, so the server was out of sync with the documented shape. Render `cards/show` for the JSON format so the response carries the moved card (with the new `board` reference). The HTML format is unchanged. Added assertions on the returned body and added an API doc entry for the endpoint, which was previously undocumented.
1 parent 58ec0cc commit 49eb3ae

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

app/controllers/cards/boards_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def update
1414

1515
respond_to do |format|
1616
format.html { redirect_to @card }
17-
format.json { head :no_content }
17+
format.json { render "cards/show" }
1818
end
1919
end
2020

docs/api/sections/cards.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,26 @@ __Response:__
251251

252252
Returns `204 No Content` on success.
253253

254+
## `PUT /:account_slug/cards/:card_number/board`
255+
256+
Moves a card to a different board.
257+
258+
| Parameter | Type | Required | Description |
259+
|-----------|------|----------|-------------|
260+
| `board_id` | string | Yes | The ID of the board to move the card to |
261+
262+
__Request:__
263+
264+
```json
265+
{
266+
"board_id": "03f5v9zkft4hj9qq0lsn9ohcm"
267+
}
268+
```
269+
270+
__Response:__
271+
272+
Returns `200 OK` with the moved card in the same shape as `GET /:account_slug/cards/:card_number`. The `board` field reflects the new board.
273+
254274
## `POST /:account_slug/cards/:card_number/triage`
255275

256276
Moves a card into a column.

test/controllers/cards/boards_controller_test.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ class Cards::BoardsControllerTest < ActionDispatch::IntegrationTest
2626

2727
put card_board_path(card), params: { board_id: new_board.id }, as: :json
2828

29-
assert_response :no_content
29+
assert_response :success
3030
assert_equal new_board, card.reload.board
31+
32+
json = @response.parsed_body
33+
assert_equal card.id, json["id"]
34+
assert_equal card.number, json["number"]
35+
assert_equal card.title, json["title"]
36+
assert_equal new_board.id, json["board"]["id"]
3137
end
3238
end

0 commit comments

Comments
 (0)