Add JSON response format to board publication toggle#2663
Add JSON response format to board publication toggle#2663robzolkos wants to merge 1 commit intobasecamp:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds JSON support for publishing/unpublishing boards so API clients can toggle public access and receive a shareable link, alongside the existing Turbo Stream behavior.
Changes:
- Add
respond_toJSON branches inBoards::PublicationsController#create/destroy(201 w/{key,url}on publish, 204 on unpublish). - Add integration tests for JSON publish/unpublish.
- Document the new Board Publications endpoints in
docs/API.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/controllers/boards/publications_controller.rb | Adds JSON responses for publish/unpublish actions alongside Turbo Stream. |
| test/controllers/boards/publications_controller_test.rb | Adds JSON request tests for publish/unpublish. |
| docs/API.md | Documents Board Publications API endpoints and example responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Allows programmatic clients to publish and unpublish boards via the API, returning the shareable key and URL on publish.
b8c0359 to
eebb196
Compare
|
|
||
| respond_to do |format| | ||
| format.turbo_stream | ||
| format.json { head :no_content } |
There was a problem hiding this comment.
Is this the default Rails response anyway? Can it be omitted?
|
|
||
| respond_to do |format| | ||
| format.turbo_stream | ||
| format.json { render json: { key: @board.publication.key, url: published_board_url(@board) }, status: :created } |
There was a problem hiding this comment.
JSON response should typically be the entity created. Would add a partial for the board publication, include it in boards/_board (if published), and then choose whether to render the publication itself or the entire board in response here.
Summary
respond_toblocks toBoards::PublicationsControllerfor JSON support alongside existing Turbo Stream responses201 Createdwith the shareablekeyand publicurl204 No Content