From: Tusooa Zhu Date: Thu, 3 Mar 2022 01:04:30 +0000 (-0500) Subject: Add test for fallbacking to a general language X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=ff0bb3a3ac56e84bb28e5e7782629b7f5a5c4ed4;p=akkoma Add test for fallbacking to a general language --- 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