Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F13521116
set_locale_plug_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
set_locale_plug_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 8:09 PM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
640054
Default Alt Text
set_locale_plug_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment