diff options
author | Luke Duncalfe <lduncalfe@eml.cc> | 2019-06-18 04:44:43 +0300 |
---|---|---|
committer | Luke Duncalfe <lduncalfe@eml.cc> | 2019-08-21 02:39:41 +0300 |
commit | 37b17fa61a1fb5efe5942ab2cb27b15685bf905e (patch) | |
tree | e9883b80bc7fe72b7e360c1f4bf32e889166b811 /app/models/award_emoji.rb | |
parent | 330cbddec30840a72a52aade383286e58545ce98 (diff) |
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.rb | 6 |
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 |