mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 16:24:23 +00:00
447514dfa2
Done via the following command:
git diff 1e6c102bfc
--stat --name-only | cat - | xargs sed -i 's/2017-2018 Pleroma Authors/2017-2019 Pleroma Authors/'
47 lines
1.1 KiB
Elixir
47 lines
1.1 KiB
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Plugs.SetLocalePlugTest do
|
|
use ExUnit.Case, async: true
|
|
use Plug.Test
|
|
|
|
alias Pleroma.Plugs.SetLocalePlug
|
|
alias Plug.Conn
|
|
|
|
test "default locale is `en`" do
|
|
conn =
|
|
:get
|
|
|> conn("/cofe")
|
|
|> SetLocalePlug.call([])
|
|
|
|
assert "en" == Gettext.get_locale()
|
|
assert %{locale: "en"} == conn.assigns
|
|
end
|
|
|
|
test "use supported locale from `accept-language`" do
|
|
conn =
|
|
:get
|
|
|> conn("/cofe")
|
|
|> Conn.put_req_header(
|
|
"accept-language",
|
|
"ru, fr-CH, fr;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 default locale if locale from `accept-language` is not supported" do
|
|
conn =
|
|
:get
|
|
|> conn("/cofe")
|
|
|> Conn.put_req_header("accept-language", "tlh")
|
|
|> SetLocalePlug.call([])
|
|
|
|
assert "en" == Gettext.get_locale()
|
|
assert %{locale: "en"} == conn.assigns
|
|
end
|
|
end
|