Commit 710bfde3 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Make AwardEmojiPresenter rely on TanukiEmoji

parent 036f3297
......@@ -4,15 +4,15 @@ class AwardEmojiPresenter < Gitlab::View::Presenter::Delegated
presents ::AwardEmoji, as: :award_emoji
def description
as_emoji['description']
as_emoji&.description
end
def unicode
as_emoji['unicode']
as_emoji&.hex
end
def emoji
as_emoji['moji']
as_emoji&.codepoints
end
def unicode_version
......@@ -22,6 +22,6 @@ class AwardEmojiPresenter < Gitlab::View::Presenter::Delegated
private
def as_emoji
@emoji ||= Gitlab::Emoji.emojis[award_emoji.name] || {}
@emoji ||= TanukiEmoji.find_by_alpha_code(award_emoji.name)
end
end
......@@ -6,13 +6,14 @@ RSpec.describe AwardEmojiPresenter do
let(:emoji_name) { 'thumbsup' }
let(:award_emoji) { build(:award_emoji, name: emoji_name) }
let(:presenter) { described_class.new(award_emoji) }
let(:emoji) { TanukiEmoji.find_by_alpha_code(emoji_name) }
describe '#description' do
it { expect(presenter.description).to eq Gitlab::Emoji.emojis[emoji_name]['description'] }
it { expect(presenter.description).to eq emoji.description }
end
describe '#unicode' do
it { expect(presenter.unicode).to eq Gitlab::Emoji.emojis[emoji_name]['unicode'] }
it { expect(presenter.unicode).to eq emoji.hex }
end
describe '#unicode_version' do
......@@ -20,7 +21,7 @@ RSpec.describe AwardEmojiPresenter do
end
describe '#emoji' do
it { expect(presenter.emoji).to eq Gitlab::Emoji.emojis[emoji_name]['moji'] }
it { expect(presenter.emoji).to eq emoji.codepoints }
end
describe 'when presenting an award emoji with an invalid name' do
......
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