mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 12:58:30 +08:00
## Summary - Merges locale-specific emoji search aliases into `/emojis/search-aliases.json` based on the user's `I18n.locale`, enabling emoji search in the user's language (e.g. "joinha" finds 👍 in pt_BR) - Removes unused `search_aliases` attribute from `/emojis.json` — it was serialized but never consumed by the frontend (saves ~160KB per request) - Requires discourse/discourse-emojis#12 to be merged and a gem release for locale data to be available ## Context https://meta.discourse.org/t/add-english-and-translated-aliases-for-emojis/86641
61 lines
1.2 KiB
Ruby
61 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe EmojisController do
|
|
fab!(:user_1, :user)
|
|
|
|
before { sign_in(user_1) }
|
|
|
|
describe "#index" do
|
|
before do
|
|
CustomEmoji.destroy_all
|
|
CustomEmoji.create!(name: "cat", upload: Fabricate(:upload))
|
|
Emoji.clear_cache
|
|
end
|
|
|
|
after do
|
|
CustomEmoji.destroy_all
|
|
Emoji.clear_cache
|
|
end
|
|
|
|
it "returns the emojis list" do
|
|
get "/emojis.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.parsed_body.keys).to eq(
|
|
%w[
|
|
smileys_&_emotion
|
|
people_&_body
|
|
animals_&_nature
|
|
food_&_drink
|
|
travel_&_places
|
|
activities
|
|
objects
|
|
symbols
|
|
flags
|
|
default
|
|
],
|
|
)
|
|
end
|
|
end
|
|
|
|
describe "#search_aliases" do
|
|
it "returns the search aliases list" do
|
|
get "/emojis/search-aliases.json"
|
|
|
|
expect(response.status).to eq(200)
|
|
expect(response.parsed_body["grinning_face"]).to include(
|
|
"cheerful",
|
|
"cheery",
|
|
"face",
|
|
"grin",
|
|
"grinning",
|
|
"happy",
|
|
"laugh",
|
|
"nice",
|
|
"smile",
|
|
"smiling",
|
|
"teeth",
|
|
)
|
|
end
|
|
end
|
|
end
|