Fix create epic REST endpoints
What does this MR do and why?
When creating an epic and assigning it to a parent using REST endpoints we are not checking that the licensed feature subepics is available or creating system notes for the relation.
Currently, these endpoints send the param parent_id
to Epics::CreateService
that creates the epic with this attribute.
This MR changes the param to parent
to make use of the existing functionality in Epics::BaseService#assign_parent_epic_for
that sets the parent using Epics::EpicLinks::CreateService
instead of the attribute.
Using the EpicLinks
service is preferable because it handles permissions and validations as well as creating system notes for both epics.
How to set up and validate locally
- Given a group
Test Group
with an existing epic (iid: 1
) create a new child epic using the epic links endpoint:export GITLAB_PAT=<your api token> curl -X POST -H "Authorization: Bearer $GITLAB_PAT" -d title=new_child_epic http://gdk.test:3000/api/v4/groups/test-group/epics/1/epics
- In rails console check the latest epic's notes
child_epic = Epic.last child_epic.notes.last.note => "added epic &1 as parent epic" child_epic.parent.notes.last.note => "added epic &2 as child epic"
- Create a new child epic using the epics endpoint:
curl -X POST -H "Authorization: Bearer $GITLAB_PAT" -d title=new_epic -d parent_id=1 http://gdk.test:3000/api/v4/groups/test-group/epics
- In rails console check the latest epic's notes
child_epic = Epic.last child_epic.notes.last.note => "added epic &1 as parent epic" child_epic.parent.notes.last.note => "added epic &3 as child epic"
The epics endpoint is used in the epic's page so it can be tested there too:
- Visit
http://gdk.test:3000/groups/test-group/-/epics/1
- Add a new child epic using the children widget
- New system notes should be created.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.