fix for int and modules

This commit is contained in:
Alex S 2019-06-22 09:01:30 +03:00
parent ddd04d1c52
commit f0fccb7578
2 changed files with 38 additions and 2 deletions

View file

@ -77,8 +77,15 @@ defp do_convert(values) when is_list(values), do: for(val <- values, do: do_conv
defp do_convert({k, v} = value) when is_tuple(value), defp do_convert({k, v} = value) when is_tuple(value),
do: %{k => do_convert(v)} do: %{k => do_convert(v)}
defp do_convert(value) when is_binary(value) or is_atom(value) or is_map(value), defp do_convert(value) when is_binary(value) or is_map(value) or is_number(value), do: value
do: value
defp do_convert(value) when is_atom(value) do
string = to_string(value)
if String.starts_with?(string, "Elixir."),
do: String.trim_leading(string, "Elixir."),
else: value
end
@spec transform(any()) :: binary() @spec transform(any()) :: binary()
def transform(entity) when is_map(entity) do def transform(entity) when is_map(entity) do

View file

@ -1463,5 +1463,34 @@ test "update config setting & delete", %{conn: conn} do
assert Application.get_env(:pleroma, :keyaa1) == "another_value" assert Application.get_env(:pleroma, :keyaa1) == "another_value"
refute Application.get_env(:pleroma, :keyaa2) refute Application.get_env(:pleroma, :keyaa2)
end end
test "common config example", %{conn: conn} do
conn =
post(conn, "/api/pleroma/admin/config", %{
configs: [
%{
"key" => "Pleroma.Captcha",
"value" => %{
"enabled" => ":false",
"method" => "Pleroma.Captcha.Kocaptcha",
"seconds_valid" => "i:60"
}
}
]
})
assert json_response(conn, 200) == %{
"configs" => [
%{
"key" => "Pleroma.Captcha",
"value" => [
%{"enabled" => false},
%{"method" => "Pleroma.Captcha.Kocaptcha"},
%{"seconds_valid" => 60}
]
}
]
}
end
end end
end end