Add PUT endpoint to update a note in a work item discussion

What does this MR do and why?

Adds PUT /-/work_items/:work_item_iid/discussions/:discussion_id/notes/:note_id to the work item REST API. It is available in three flavours:

  • /namespaces/:id/-/work_items/...
  • /projects/:id/-/work_items/...
  • /groups/:id/-/work_items/...

The endpoint updates a single comment (note) inside a discussion thread on a work item. It takes one of these params:

  • body: edits the note text.
  • resolved: boolean, resolves or unresolves that one note.

Exactly one of the two must be given (exactly_one_of :body, :resolved). Otherwise the API returns 400.

It mirrors the legacy PUT /projects/:id/issues/:iid/discussions/:discussion_id/notes/:note_id endpoint. Issues and work items share the same record, so the behavior matches.

References

Screenshots or screen recordings

No UI changes.

How to set up and validate locally

  1. Enable the flag in a Rails console: Feature.enable(:work_item_rest_api)

  2. Create a project with an issue work item. Start a discussion thread on it, for example with the existing endpoint POST /api/v4/projects/:id/-/work_items/:work_item_iid/discussions with body=hello. Note the id of the discussion and the id of its note from the response.

  3. Edit the body. Expect 200 with the updated body.

    curl --request PUT \
      --header "PRIVATE-TOKEN: <your_access_token>" \
      --url "http://gdk.test:3000/api/v4/projects/<project_id>/-/work_items/<iid>/discussions/<discussion_id>/notes/<note_id>" \
      --data "body=updated text"
  4. Resolve the note. Use the same URL with the data below. Expect 200 with "resolved": true, and resolved_by and resolved_at set. Then send resolved=false to unresolve.

    curl --request PUT \
      --header "PRIVATE-TOKEN: <your_access_token>" \
      --url "http://gdk.test:3000/api/v4/projects/<project_id>/-/work_items/<iid>/discussions/<discussion_id>/notes/<note_id>" \
      --data "resolved=true"
  5. Send both body and resolved, or neither. Expect 400.

  6. Repeat with the /groups/<group_id>/-/work_items/... flavour on an epic work item. Repeat with /namespaces/<full_path_url_encoded>/-/work_items/....

  7. Run the specs:

    bundle exec rspec spec/requests/api/work_items/discussion_notes_spec.rb ee/spec/requests/api/work_items/discussion_notes_spec.rb

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.


This is part 1 of 3 in a stack made with GitButler:

Edited by Tetiana Chupryna

Merge request reports

Loading
Loading