Commit f8ef6978 authored by James Lopez's avatar James Lopez

Merge branch 'georgekoltsov/fix-award-emojis-import-export' into 'master'

Allow duplicate award emoji when Importing

See merge request gitlab-org/gitlab!28588
parents fbbf3d31 6f466acc
......@@ -15,7 +15,7 @@ class AwardEmoji < ApplicationRecord
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?
validates :name, uniqueness: { scope: [:user, :awardable_type, :awardable_id] }, unless: -> { ghost_user? || importing? }
participant :user
......
---
title: Allow award emoji same name & user duplicates when Importing
merge_request: 28588
author:
type: fixed
......@@ -41,6 +41,22 @@ describe AwardEmoji do
expect(new_award).to be_valid
end
# Similar to allowing duplicate award emojis for ghost users,
# when Importing a project that has duplicate award emoji placed by
# ghost user we change the author to be importer user and allow
# duplicates, otherwise relation containing such duplicates
# fails to be created
context 'when importing' do
it 'allows duplicate award emoji' do
user = create(:user)
issue = create(:issue)
create(:award_emoji, user: user, awardable: issue)
new_award = build(:award_emoji, user: user, awardable: issue, importing: true)
expect(new_award).to be_valid
end
end
end
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