Commit 97fd9616 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'emoji_category_fix' into 'master'

Emoji categories fix

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/14020

See merge request !3727
parents 9cd5e0fc 6ae2680c
...@@ -67,6 +67,7 @@ v 8.7.0 (unreleased) ...@@ -67,6 +67,7 @@ v 8.7.0 (unreleased)
- Improved markdown forms - Improved markdown forms
- Diffs load at the correct point when linking from from number - Diffs load at the correct point when linking from from number
- Selected diff rows highlight - Selected diff rows highlight
- Fix emoji catgories in the emoji picker
v 8.6.6 v 8.6.6
- Fix error on language detection when repository has no HEAD (e.g., master branch). !3654 (Jeroen Bobbeldijk) - Fix error on language detection when repository has no HEAD (e.g., master branch). !3654 (Jeroen Bobbeldijk)
......
...@@ -14,19 +14,29 @@ class AwardEmoji ...@@ -14,19 +14,29 @@ class AwardEmoji
food_drink: "Food" food_drink: "Food"
}.with_indifferent_access }.with_indifferent_access
CATEGORY_ALIASES = {
symbols: "objects_symbols",
foods: "food_drink",
travel: "travel_places"
}.with_indifferent_access
def self.normilize_emoji_name(name) def self.normilize_emoji_name(name)
aliases[name] || name aliases[name] || name
end end
def self.emoji_by_category def self.emoji_by_category
unless @emoji_by_category unless @emoji_by_category
@emoji_by_category = {} @emoji_by_category = Hash.new { |h, key| h[key] = [] }
emojis.each do |emoji_name, data| emojis.each do |emoji_name, data|
data["name"] = emoji_name data["name"] = emoji_name
@emoji_by_category[data["category"]] ||= [] # Skip Fitzpatrick(tone) modifiers
@emoji_by_category[data["category"]] << data next if data["category"] == "modifier"
category = CATEGORY_ALIASES[data["category"]] || data["category"]
@emoji_by_category[category] << data
end end
@emoji_by_category = @emoji_by_category.sort.to_h @emoji_by_category = @emoji_by_category.sort.to_h
......
...@@ -16,4 +16,11 @@ describe AwardEmoji do ...@@ -16,4 +16,11 @@ describe AwardEmoji do
end end
end end
end end
describe '.emoji_by_category' do
it "only contains known categories" do
undefined_categories = AwardEmoji.emoji_by_category.keys - AwardEmoji::CATEGORIES.keys
expect(undefined_categories).to be_empty
end
end
end end
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