gitlab-org--gitlab-foss/app/models/award_emoji.rb
Connor Shea f31f78cea3
Add emoji.rb in lib/gitlab instead of using the gitlab_emoji gem.
No reason to split it into a separate gem when the gem barely did anything. We can use gemojione directly, making updating gemojione that much easier.

Also fix the Rake task and update gemojione to 2.6.1. This adds the EmojiOne Spring update.

Changelog: https://github.com/jonathanwiesel/gemojione/blob/master/CHANGELOG.md
2016-06-29 14:53:09 -06:00

26 lines
645 B
Ruby

class AwardEmoji < ActiveRecord::Base
DOWNVOTE_NAME = "thumbsdown".freeze
UPVOTE_NAME = "thumbsup".freeze
include Participable
belongs_to :awardable, polymorphic: true
belongs_to :user
validates :awardable, :user, presence: true
validates :name, presence: true, inclusion: { in: Gitlab::Emoji.emojis_names }
validates :name, uniqueness: { scope: [:user, :awardable_type, :awardable_id] }
participant :user
scope :downvotes, -> { where(name: DOWNVOTE_NAME) }
scope :upvotes, -> { where(name: UPVOTE_NAME) }
def downvote?
self.name == DOWNVOTE_NAME
end
def upvote?
self.name == UPVOTE_NAME
end
end