diff options
author | Tusooa Zhu <tusooa@kazv.moe> | 2022-03-02 20:04:30 -0500 |
---|---|---|
committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-03-02 20:04:30 -0500 |
commit | bc59da96c52a0fe751154dd98405e11817029b23 (patch) | |
tree | d4acf4064c99ff90a8469d43038d276ca616cc81 | |
parent | 8de573b04783ef50b74bd629843a58b37c0ce31d (diff) | |
download | pleroma-bc59da96c52a0fe751154dd98405e11817029b23.tar.gz |
Add test for fallbacking to a general language
-rw-r--r-- | test/pleroma/web/plugs/set_locale_plug_test.exs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/pleroma/web/plugs/set_locale_plug_test.exs b/test/pleroma/web/plugs/set_locale_plug_test.exs index 349326c24..f5d3ab995 100644 --- a/test/pleroma/web/plugs/set_locale_plug_test.exs +++ b/test/pleroma/web/plugs/set_locale_plug_test.exs @@ -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 |