diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 3d5485f1ff..3f242bcb8d 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -50,7 +50,13 @@ def update redirect_to root_path, notice: "Saved (you were removed from the board)" end end - format.json { head :no_content } + format.json do + if @board.accessible_to?(Current.user) + render :show + else + head :no_content + end + end end end diff --git a/docs/api/sections/boards.md b/docs/api/sections/boards.md index fcce327628..11e5a43fb7 100644 --- a/docs/api/sections/boards.md +++ b/docs/api/sections/boards.md @@ -126,7 +126,33 @@ __Request:__ __Response:__ -Returns `204 No Content` on success. +Returns `200 OK` with the updated board in the same shape as `GET /:account_slug/boards/:board_id`: + +```json +{ + "id": "03f5v9zkft4hj9qq0lsn9ohcm", + "name": "Updated board name", + "all_access": false, + "created_at": "2025-12-05T19:36:35.534Z", + "auto_postpone_period_in_days": 30, + "url": "http://app.fizzy.localhost:3006/897362094/boards/03f5v9zkft4hj9qq0lsn9ohcm", + "creator": { + "id": "03f5v9zjw7pz8717a4no1h8a7", + "name": "David Heinemeier Hansson", + "role": "owner", + "active": true, + "email_address": "david@example.com", + "created_at": "2025-12-05T19:36:35.401Z", + "url": "http://app.fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7" + }, + "user_ids": [ + "03f5v9zppzlksuj4mxba2nbzn", + "03f5v9zjw7pz8717a4no1h8a7" + ] +} +``` + +If the update succeeds but removes the requesting user's own access to the board, the endpoint instead returns `204 No Content`. ## `DELETE /:account_slug/boards/:board_id` diff --git a/test/controllers/api/flat_json_params_test.rb b/test/controllers/api/flat_json_params_test.rb index 77a74f454e..d8e8faa5e5 100644 --- a/test/controllers/api/flat_json_params_test.rb +++ b/test/controllers/api/flat_json_params_test.rb @@ -104,11 +104,13 @@ class FlatJsonParamsTest < ActionDispatch::IntegrationTest params: { name: "Flat board", auto_postpone_period_in_days: 7, public_description: "
Flat public desc
" }, as: :json - assert_response :no_content + assert_response :success board.reload assert_equal "Flat board", board.name assert_equal 7.days, board.entropy.auto_postpone_period assert_equal "Flat public desc", board.public_description.to_plain_text + assert_equal board.id, @response.parsed_body["id"] + assert_equal "Flat board", @response.parsed_body["name"] end test "create column with flat JSON" do diff --git a/test/controllers/boards_controller_test.rb b/test/controllers/boards_controller_test.rb index e4d4d3103b..896b504382 100644 --- a/test/controllers/boards_controller_test.rb +++ b/test/controllers/boards_controller_test.rb @@ -344,8 +344,27 @@ class BoardsControllerTest < ActionDispatch::IntegrationTest put board_path(board), params: { board: { name: "Updated Name" } }, as: :json + assert_response :success + assert_equal "Updated Name", board.reload.name + + json = @response.parsed_body + assert_equal board.id, json["id"] + assert_equal "Updated Name", json["name"] + assert_equal board.creator.id, json["creator"]["id"] + end + + test "update as JSON returns no content when user removes themselves from board" do + board = boards(:writebook) + + put board_path(board), params: { + board: { name: "Updated Name", all_access: false }, + user_ids: users(:david, :jz).pluck(:id) + }, as: :json + assert_response :no_content assert_equal "Updated Name", board.reload.name + assert_not board.users.include?(users(:kevin)) + assert_empty response.body end test "destroy as JSON" do