Add test for fallbacking to a general language
authorTusooa Zhu <tusooa@kazv.moe>
Thu, 3 Mar 2022 01:04:30 +0000 (20:04 -0500)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:47:10 +0000 (20:47 +0100)
test/pleroma/web/plugs/set_locale_plug_test.exs

index 349326c245878c1ceb48deb30504c87fc8c8ecc4..f5d3ab995d69def1fefde6ab57b394c8f8a47a8f 100644 (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