diff --git a/app/controllers/cards/boards_controller.rb b/app/controllers/cards/boards_controller.rb index 3444cd3452..3c26607a56 100644 --- a/app/controllers/cards/boards_controller.rb +++ b/app/controllers/cards/boards_controller.rb @@ -14,7 +14,7 @@ def update respond_to do |format| format.html { redirect_to @card } - format.json { head :no_content } + format.json { render "cards/show" } end end diff --git a/docs/api/sections/cards.md b/docs/api/sections/cards.md index 1597b98e33..800ed82088 100644 --- a/docs/api/sections/cards.md +++ b/docs/api/sections/cards.md @@ -251,6 +251,26 @@ __Response:__ Returns `204 No Content` on success. +## `PUT /:account_slug/cards/:card_number/board` + +Moves a card to a different board. + +| Parameter | Type | Required | Description | +|-----------|------|----------|-------------| +| `board_id` | string | Yes | The ID of the board to move the card to | + +__Request:__ + +```json +{ + "board_id": "03f5v9zkft4hj9qq0lsn9ohcm" +} +``` + +__Response:__ + +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. + ## `POST /:account_slug/cards/:card_number/triage` Moves a card into a column. diff --git a/test/controllers/cards/boards_controller_test.rb b/test/controllers/cards/boards_controller_test.rb index ebadff9b98..6be06ce823 100644 --- a/test/controllers/cards/boards_controller_test.rb +++ b/test/controllers/cards/boards_controller_test.rb @@ -26,7 +26,13 @@ class Cards::BoardsControllerTest < ActionDispatch::IntegrationTest put card_board_path(card), params: { board_id: new_board.id }, as: :json - assert_response :no_content + assert_response :success assert_equal new_board, card.reload.board + + json = @response.parsed_body + assert_equal card.id, json["id"] + assert_equal card.number, json["number"] + assert_equal card.title, json["title"] + assert_equal new_board.id, json["board"]["id"] end end