Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/controllers/boards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
robzolkos marked this conversation as resolved.
end
end
end
end

Expand Down
28 changes: 27 additions & 1 deletion docs/api/sections/boards.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
```
Comment thread
robzolkos marked this conversation as resolved.

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`

Expand Down
4 changes: 3 additions & 1 deletion test/controllers/api/flat_json_params_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ class FlatJsonParamsTest < ActionDispatch::IntegrationTest
params: { name: "Flat board", auto_postpone_period_in_days: 7, public_description: "<p>Flat public desc</p>" },
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
Expand Down
19 changes: 19 additions & 0 deletions test/controllers/boards_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down