summaryrefslogtreecommitdiff
path: root/app/models/award_emoji.rb
diff options
context:
space:
mode:
authorLuke Duncalfe <lduncalfe@eml.cc>2019-06-18 13:44:43 +1200
committerLuke Duncalfe <lduncalfe@eml.cc>2019-08-21 11:39:41 +1200
commit37b17fa61a1fb5efe5942ab2cb27b15685bf905e (patch)
treee9883b80bc7fe72b7e360c1f4bf32e889166b811 /app/models/award_emoji.rb
parent330cbddec30840a72a52aade383286e58545ce98 (diff)
downloadgitlab-ce-37b17fa61a1fb5efe5942ab2cb27b15685bf905e.tar.gz
Add service classes for mutating AwardEmoji
Adding, destroying and toggling emoji previously lacked services and instead were performed through methods called on Awardable models. This led to inconsistencies where relevant todos would be marked as done only when emoji were awarded through our controllers, but not through the API. Todos could also be marked as done when an emoji was being removed. Behaviour changes - Awarding emoji through the API will now mark a relevant Todo as done - Toggling an emoji off (destroying it) through our controllers will no longer mark a relevant Todo as done Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63372
Diffstat (limited to 'app/models/award_emoji.rb')
-rw-r--r--app/models/award_emoji.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index e26162f6151..0ab302a0f3e 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -16,8 +16,10 @@ class AwardEmoji < ApplicationRecord
participant :user
- scope :downvotes, -> { where(name: DOWNVOTE_NAME) }
- scope :upvotes, -> { where(name: UPVOTE_NAME) }
+ scope :downvotes, -> { named(DOWNVOTE_NAME) }
+ scope :upvotes, -> { named(UPVOTE_NAME) }
+ scope :named, -> (names) { where(name: names) }
+ scope :awarded_by, -> (users) { where(user: users) }
after_save :expire_etag_cache
after_destroy :expire_etag_cache