Project Import does not restore snippets having `award_emoji`
Summary
Project Import could only restore Snippets
without AwardEmoji
(reaction emojis).
Steps to reproduce
On your test project, create three snippets:
First, just a simple one.
Second, with some emoji reactions.
Third, with a comment.
Export the project.
Import it using the tar from the Export ^.
In the restored project, not all snippets will be restored.
Example Project
Any pre-seeded project will work.
What is the current bug behavior?
As for award_emoji
– it fails because the award_emoji
model validation fails (and as a result – a snippet
validation too).
What is the expected correct behavior?
We should be able to restore any snippet which is present in our export.
With comments (notes), with emoji, snippets not having any of the above.
Relevant logs and/or screenshots
Example snippet section in the exported project:
"snippets": [
{
"id": 54,
"title": "Snippet WITH emoji",
"content": "y = 3",
"author_id": 1,
"project_id": 26,
"created_at": "2019-11-06T11:44:52.611Z",
"updated_at": "2019-11-06T11:45:06.862Z",
"file_name": "",
"visibility_level": 20,
"description": "Desc2y =",
"award_emoji": [
{
"id": 298,
"name": "thumbsup",
"user_id": 1,
"awardable_type": "Snippet",
"created_at": "2019-11-06T11:44:55.767Z",
"updated_at": "2019-11-06T11:44:55.767Z"
},
{
"id": 299,
"name": "coffee",
"user_id": 1,
"awardable_type": "Snippet",
"created_at": "2019-11-06T11:44:58.482Z",
"updated_at": "2019-11-06T11:44:58.482Z"
}
],
"notes": [
{
"id": 148649,
"note": "Comment on snippet WITH emoji",
"noteable_type": "Snippet",
"author_id": 1,
"created_at": "2019-11-06T11:45:06.848Z",
"updated_at": "2019-11-06T11:45:06.848Z",
"project_id": 26,
"attachment": {
"url": null
},
"line_code": null,
"commit_id": null,
"noteable_id": 54,
"system": false,
"st_diff": null,
"updated_by_id": null,
"position": null,
"original_position": null,
"resolved_at": null,
"resolved_by_id": null,
"discussion_id": "8cc0c703e773af3b18a9b4578316f27ff2ea4116",
"change_position": null,
"resolved_by_push": null,
"review_id": null,
"type": null,
"author": {
"name": "Administrator"
}
}
]
},
{
"id": 53,
"title": "Snippet WITHOUT emoji",
"content": "x = 1",
"author_id": 1,
"project_id": 26,
"created_at": "2019-11-06T11:44:06.567Z",
"updated_at": "2019-11-06T11:44:26.011Z",
"file_name": "",
"visibility_level": 20,
"description": "Desc",
"award_emoji": [],
"notes": [
{
"id": 148648,
"note": "Comment on Snippet WITHOUT emoji",
"noteable_type": "Snippet",
"author_id": 1,
"created_at": "2019-11-06T11:44:25.988Z",
"updated_at": "2019-11-06T11:44:25.988Z",
"project_id": 26,
"attachment": {
"url": null
},
"line_code": null,
"commit_id": null,
"noteable_id": 53,
"system": false,
"st_diff": null,
"updated_by_id": null,
"position": null,
"original_position": null,
"resolved_at": null,
"resolved_by_id": null,
"discussion_id": "ec52f6a334a7a6ea9c878a0a30990bb1159aa678",
"change_position": null,
"resolved_by_push": null,
"review_id": null,
"type": null,
"author": {
"name": "Administrator"
}
}
]
}
],
Possible fixes
Validate the snippet in a similar way we validate other polymorphic folded relations (e.g. notes
).