summaryrefslogtreecommitdiff
path: root/spec/models/award_emoji_spec.rb
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2017-04-06 15:36:36 +0530
committerTimothy Andrew <mail@timothyandrew.net>2017-04-06 18:59:17 +0530
commit3e1a1242c67781fb52940433c5ad1bbefd346216 (patch)
tree5f45e1f2dfee8ac69c0ee6340e2cc01ac5273817 /spec/models/award_emoji_spec.rb
parent682987547a932c011f84c6455f0fd32bb500b308 (diff)
downloadgitlab-ce-3e1a1242c67781fb52940433c5ad1bbefd346216.tar.gz
Move a user's award emoji to the ghost user
... when the user is destroyed. 1. Normally, for a given awardable and award emoji name, a user is only allowed to create a single award emoji. 2. This validation needs to be removed for ghost users, since: - User A and User B have created award emoji - with the same name and against the same awardable - User A is deleted. Their award emoji is moved to the ghost user - User B is deleted. Their award emoji needs to be moved to the ghost user. However, this breaks the uniqueness validation, since the ghost user is only allowed to have one award emoji of a given name for a given awardable
Diffstat (limited to 'spec/models/award_emoji_spec.rb')
-rw-r--r--spec/models/award_emoji_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/award_emoji_spec.rb b/spec/models/award_emoji_spec.rb
index cb3c592f8cd..2a9a27752c1 100644
--- a/spec/models/award_emoji_spec.rb
+++ b/spec/models/award_emoji_spec.rb
@@ -25,6 +25,20 @@ describe AwardEmoji, models: true do
expect(new_award).not_to be_valid
end
+
+ # Assume User A and User B both created award emoji of the same name
+ # on the same awardable. When User A is deleted, User A's award emoji
+ # is moved to the ghost user. When User B is deleted, User B's award emoji
+ # also needs to be moved to the ghost user - this cannot happen unless
+ # the uniqueness validation is disabled for ghost users.
+ it "allows duplicate award emoji for ghost users" do
+ user = create(:user, :ghost)
+ issue = create(:issue)
+ create(:award_emoji, user: user, awardable: issue)
+ new_award = build(:award_emoji, user: user, awardable: issue)
+
+ expect(new_award).to be_valid
+ end
end
end
end