FIX: do not include group less emojis in standard list (#18659)
This commit is contained in:
parent
437de6338e
commit
a705e4815f
|
@ -88,13 +88,14 @@ class Emoji
|
||||||
|
|
||||||
def self.create_from_db_item(emoji)
|
def self.create_from_db_item(emoji)
|
||||||
name = emoji["name"]
|
name = emoji["name"]
|
||||||
|
return unless group = groups[name]
|
||||||
filename = emoji['filename'] || name
|
filename = emoji['filename'] || name
|
||||||
|
|
||||||
Emoji.new.tap do |e|
|
Emoji.new.tap do |e|
|
||||||
e.name = name
|
e.name = name
|
||||||
e.tonable = Emoji.tonable_emojis.include?(name)
|
e.tonable = Emoji.tonable_emojis.include?(name)
|
||||||
e.url = Emoji.url_for(filename)
|
e.url = Emoji.url_for(filename)
|
||||||
e.group = groups[name] || DEFAULT_GROUP
|
e.group = group
|
||||||
e.search_aliases = search_aliases[name] || []
|
e.search_aliases = search_aliases[name] || []
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -151,7 +152,7 @@ class Emoji
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_standard
|
def self.load_standard
|
||||||
db['emojis'].map { |e| Emoji.create_from_db_item(e) }
|
db['emojis'].map { |e| Emoji.create_from_db_item(e) }.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_custom
|
def self.load_custom
|
||||||
|
|
|
@ -143,15 +143,26 @@ RSpec.describe Emoji do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".load_standard" do
|
||||||
|
it "removes nil emojis" do
|
||||||
|
expect(Emoji.load_standard.any? { |element| element.nil? }).to be false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#create_from_db_item" do
|
describe "#create_from_db_item" do
|
||||||
it "sets the group of the emoji" do
|
it "sets the group of the emoji" do
|
||||||
emoji = Emoji.create_from_db_item("name" => "scotland")
|
emoji = Emoji.create_from_db_item("name" => "scotland")
|
||||||
expect(emoji.group).to eq("flags")
|
expect(emoji.group).to eq("flags")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "sets the search aliases of the emoji" do
|
it "sets the group of the emoji" do
|
||||||
emoji = Emoji.create_from_db_item("name" => "sad")
|
emoji = Emoji.create_from_db_item("name" => "scotland")
|
||||||
expect(emoji.search_aliases).to contain_exactly("frowning_face", "slightly_frowning_face", "sob", "crying_cat_face", "cry", "face_holding_back_tears")
|
expect(emoji.group).to eq("flags")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn’t create emoji when group is unknown" do
|
||||||
|
emoji = Emoji.create_from_db_item("name" => "white_hair")
|
||||||
|
expect(emoji).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue