diff --git a/app/views/boards/_board.json.jbuilder b/app/views/boards/_board.json.jbuilder index 0eeff1896..586835c38 100644 --- a/app/views/boards/_board.json.jbuilder +++ b/app/views/boards/_board.json.jbuilder @@ -6,5 +6,9 @@ json.cache! board do json.creator board.creator, partial: "users/user", as: :user - json.public_url published_board_url(board) if board.published? + if board.published? + json.public_description board.public_description.to_plain_text + json.public_description_html board.public_description.to_s + json.public_url published_board_url(board) + end end diff --git a/app/views/boards/show.json.jbuilder b/app/views/boards/show.json.jbuilder index a6916c467..08c345660 100644 --- a/app/views/boards/show.json.jbuilder +++ b/app/views/boards/show.json.jbuilder @@ -1 +1,2 @@ json.partial! "boards/board", board: @board +json.user_ids @board.users.ids unless @board.all_access? diff --git a/docs/api/sections/boards.md b/docs/api/sections/boards.md index bf77245ab..b3157cdcd 100644 --- a/docs/api/sections/boards.md +++ b/docs/api/sections/boards.md @@ -40,7 +40,7 @@ __Response:__ { "id": "03f5v9zkft4hj9qq0lsn9ohcm", "name": "Fizzy", - "all_access": true, + "all_access": false, "created_at": "2025-12-05T19:36:35.534Z", "auto_postpone_period_in_days": 30, "url": "http://fizzy.localhost:3006/897362094/boards/03f5v9zkft4hj9qq0lsn9ohcm", @@ -53,11 +53,17 @@ __Response:__ "created_at": "2025-12-05T19:36:35.401Z", "url": "http://fizzy.localhost:3006/897362094/users/03f5v9zjw7pz8717a4no1h8a7" }, + "public_description": "Follow along with public product updates.", + "public_description_html": "
Follow along with public product updates.
Public board description.
") + + get boards_path, as: :json + assert_response :success + + published_board = @response.parsed_body.find { |b| b["id"] == board.id } + assert_equal board.public_description.to_plain_text, published_board["public_description"] + assert_equal board.public_description.to_s, published_board["public_description_html"] + end + test "index as JSON paginates and preserves recently-accessed order" do account = accounts("37s") kevin = users(:kevin) @@ -261,6 +274,43 @@ class BoardsControllerTest < ActionDispatch::IntegrationTest assert_equal boards(:writebook).auto_postpone_period_in_days, @response.parsed_body["auto_postpone_period_in_days"] end + test "show as JSON includes public_description fields when published" do + board = boards(:writebook) + board.publish + board.update!(public_description: "This is a public note.
") + + get board_path(board), as: :json + assert_response :success + assert_equal board.public_description.to_plain_text, @response.parsed_body["public_description"] + assert_equal board.public_description.to_s, @response.parsed_body["public_description_html"] + end + + test "show as JSON excludes public_description fields when not published" do + board = boards(:writebook) + board.update!(public_description: "This is a public note.
") + assert_not board.published? + + get board_path(board), as: :json + assert_response :success + assert_nil @response.parsed_body["public_description"] + assert_nil @response.parsed_body["public_description_html"] + end + + test "show as JSON includes granted user_ids when board is not all access" do + board = boards(:private) + board.accesses.revise granted: users(:david, :jz), revoked: [] + + get board_path(board), as: :json + assert_response :success + assert_equal board.users.ids.sort, @response.parsed_body["user_ids"].sort + end + + test "show as JSON excludes user_ids when board is all access" do + get board_path(boards(:writebook)), as: :json + assert_response :success + assert_nil @response.parsed_body["user_ids"] + end + test "show as JSON includes public_url when published" do board = boards(:writebook) board.publish