Add test for fallbacking to a general language

This commit is contained in:
Tusooa Zhu 2022-03-02 20:04:30 -05:00 committed by FloatingGhost
parent ef73f61b07
commit ff0bb3a3ac

View file

@ -33,6 +33,20 @@ defmodule Pleroma.Web.Plugs.SetLocalePlugTest do
assert %{locale: "ru"} == conn.assigns
end
test "fallback to the general language if a variant is not supported" do
conn =
:get
|> conn("/cofe")
|> Conn.put_req_header(
"accept-language",
"ru-CA;q=0.9, en;q=0.8, *;q=0.5"
)
|> SetLocalePlug.call([])
assert "ru" == Gettext.get_locale()
assert %{locale: "ru"} == conn.assigns
end
test "use supported locale with specifiers from `accept-language`" do
conn =
:get