Commit 4753e8a8 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '35731-fix-snippets-with-emoji-import' into 'master'

Resolve "Project Import does not restore snippets having `award_emoji`"

Closes #35731

See merge request gitlab-org/gitlab!19690
parents 16c2ad5b f9c6ad70
......@@ -6,11 +6,14 @@ class AwardEmoji < ApplicationRecord
include Participable
include GhostUser
include Importable
belongs_to :awardable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :user
validates :awardable, :user, presence: true
validates :user, presence: true
validates :awardable, presence: true, unless: :importing?
validates :name, presence: true, inclusion: { in: Gitlab::Emoji.emojis_names }
validates :name, uniqueness: { scope: [:user, :awardable_type, :awardable_id] }, unless: :ghost_user?
......
---
title: Fix import of snippets having `award_emoji` (Project Export/Import)
merge_request: 19690
author:
type: fixed
......@@ -2260,7 +2260,41 @@
]
}
],
"snippets": [],
"snippets": [
{
"id": 1,
"title": "Test snippet title",
"content": "x = 1",
"author_id": 1,
"project_id": 1,
"created_at": "2019-11-05T15:06:06.579Z",
"updated_at": "2019-11-05T15:06:06.579Z",
"file_name": "",
"visibility_level": 20,
"description": "Test snippet description",
"award_emoji": [
{
"id": 1,
"name": "thumbsup",
"user_id": 1,
"awardable_type": "Snippet",
"awardable_id": 1,
"created_at": "2019-11-05T15:37:21.287Z",
"updated_at": "2019-11-05T15:37:21.287Z"
},
{
"id": 2,
"name": "coffee",
"user_id": 1,
"awardable_type": "Snippet",
"awardable_id": 1,
"created_at": "2019-11-05T15:37:24.645Z",
"updated_at": "2019-11-05T15:37:24.645Z"
}
],
"notes": []
}
],
"releases": [],
"project_members": [
{
......
......@@ -210,6 +210,16 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(@project.project_badges.count).to eq(2)
end
it 'has snippets' do
expect(@project.snippets.count).to eq(1)
end
it 'has award emoji for a snippet' do
award_emoji = @project.snippets.first.award_emoji
expect(award_emoji.map(&:name)).to contain_exactly('thumbsup', 'coffee')
end
it 'restores the correct service' do
expect(CustomIssueTrackerService.first).not_to be_nil
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment