[Step2|BE] Define snippet multi action specification
Now that we almost have the new snippet_files param in the services and in GraphQL API, we need to define the info that array will have and check that once the services get it, they apply the proper changes.
I propose to use the same definition we have for the web IDE. In the following image, we have what info we need to pass per each action:
We need to ensure that Snippets::CreateService and Snippets::UpdateService can apply that definition to the repository properly.
For the Snippets::CreateService we need to ensure that we only accept create actions, because others don't make sense.
We need to update as well the validation in SnippetInputAction to match the necessary requirements according to the action.
After checking with FE, the specification of the actions and the fields inside them, is like this:
-
Createaction. We will use this action to create files with content-
action->create file_pathcontent
-
-
Updateaction. We will use this action to update only the file content-
action->update file_pathcontent- Optional (but not needed at all):
previous_path. If present, it's value has to be the same asfile_path.
-
-
Deleteaction. We will use this action to delete files-
action->delete file_path
-
-
Moveaction. We will use this action to rename files or to rename files + update content at the same time.-
action->move file_path-
previous_path. Its value has to be different fromfile_path - Optional:
content
-
For this we have to update the following:
-
In the Snippets::UpdateServicewe have to update https://gitlab.com/gitlab-org/gitlab/blob/master/app/services/snippets/update_service.rb#L41 to only set thecontentif it is present in the action. If we have an action likedeletewithout a content and we don't change this, the content in the db will always be set tonil. - Update
SnippetInputAction:-
For the moveaction, add a validation to ensure that theprevious_pathis different from thefile_path
-
-
Add specs for the Snippets::UpdateServiceto check every action and the combination of them.
