From 5eb1a1aaca7ef6f95d3cff2baee7c4517e5aa70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 27 Jul 2017 01:02:15 +0200 Subject: [PATCH] Fix multipoint shortcode bug (#4387) * Fix multipoint shortcode bug * Added testcase for composite emoji shortcode --- app/lib/emoji.rb | 2 +- spec/helpers/emoji_helper_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/lib/emoji.rb b/app/lib/emoji.rb index e444b68937..6de70e9b41 100644 --- a/app/lib/emoji.rb +++ b/app/lib/emoji.rb @@ -32,7 +32,7 @@ class Emoji def codepoint_to_unicode(codepoint) if codepoint.include?('-') - codepoint.split('-').map(&:hex).pack('U') + codepoint.split('-').map(&:hex).pack('U*') else [codepoint.hex].pack('U') end diff --git a/spec/helpers/emoji_helper_spec.rb b/spec/helpers/emoji_helper_spec.rb index 1eedfb7194..6edf7672f7 100644 --- a/spec/helpers/emoji_helper_spec.rb +++ b/spec/helpers/emoji_helper_spec.rb @@ -7,6 +7,11 @@ RSpec.describe EmojiHelper, type: :helper do expect(emojify(text)).to eq '📖 Book' end + it 'converts composite emoji shortcodes to unicode' do + text = ':couple_ww:' + expect(emojify(text)).to eq '👩❤👩' + end + it 'does not convert shortcodes that are part of a string into unicode' do text = ':see_no_evil::hear_no_evil::speak_no_evil:' expect(emojify(text)).to eq text