added test

This commit is contained in:
Maksim Pechnikov 2020-08-07 09:47:05 +03:00
parent 8bb5441547
commit 6e6276b4f8
2 changed files with 74 additions and 4 deletions

View File

@ -982,8 +982,7 @@ config :pleroma, :config_description, [
%{ %{
key: :message, key: :message,
type: :string, type: :string,
description: description: "A message that will be sent to newly registered users",
"A message that will be sent to newly registered users",
suggestions: [ suggestions: [
"Hi, @username! Welcome on board!" "Hi, @username! Welcome on board!"
] ]
@ -3552,13 +3551,15 @@ config :pleroma, :config_description, [
key: "name", key: "name",
label: "Name", label: "Name",
type: :string, type: :string,
description: "Name of the installed primary frontend. Valid config must include both `Name` and `Reference` values." description:
"Name of the installed primary frontend. Valid config must include both `Name` and `Reference` values."
}, },
%{ %{
key: "ref", key: "ref",
label: "Reference", label: "Reference",
type: :string, type: :string,
description: "Reference of the installed primary frontend to be used. Valid config must include both `Name` and `Reference` values." description:
"Reference of the installed primary frontend to be used. Valid config must include both `Name` and `Reference` values."
} }
] ]
} }

View File

@ -1342,6 +1342,75 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
args: ["auto-orient", "strip", {"implode", "1"}, {"resize", "3840x1080>"}] args: ["auto-orient", "strip", {"implode", "1"}, {"resize", "3840x1080>"}]
] ]
end end
test "enables the welcome messages", %{conn: conn} do
clear_config([:welcome])
params = %{
"group" => ":pleroma",
"key" => ":welcome",
"value" => [
%{
"tuple" => [
":direct_message",
[
%{"tuple" => [":enabled", true]},
%{"tuple" => [":message", "Welcome to Pleroma!"]},
%{"tuple" => [":sender_nickname", "pleroma"]}
]
]
},
%{
"tuple" => [
":chat_message",
[
%{"tuple" => [":enabled", true]},
%{"tuple" => [":message", "Welcome to Pleroma!"]},
%{"tuple" => [":sender_nickname", "pleroma"]}
]
]
},
%{
"tuple" => [
":email",
[
%{"tuple" => [":enabled", true]},
%{"tuple" => [":sender", %{"tuple" => ["pleroma@dev.dev", "Pleroma"]}]},
%{"tuple" => [":subject", "Welcome to <%= instance_name %>!"]},
%{"tuple" => [":html", "Welcome to <%= instance_name %>!"]},
%{"tuple" => [":text", "Welcome to <%= instance_name %>!"]}
]
]
}
]
}
refute Pleroma.User.WelcomeEmail.enabled?()
refute Pleroma.User.WelcomeMessage.enabled?()
refute Pleroma.User.WelcomeChatMessage.enabled?()
res =
assert conn
|> put_req_header("content-type", "application/json")
|> post("/api/pleroma/admin/config", %{"configs" => [params]})
|> json_response_and_validate_schema(200)
assert Pleroma.User.WelcomeEmail.enabled?()
assert Pleroma.User.WelcomeMessage.enabled?()
assert Pleroma.User.WelcomeChatMessage.enabled?()
assert res == %{
"configs" => [
%{
"db" => [":direct_message", ":chat_message", ":email"],
"group" => ":pleroma",
"key" => ":welcome",
"value" => params["value"]
}
],
"need_reboot" => false
}
end
end end
describe "GET /api/pleroma/admin/config/descriptions" do describe "GET /api/pleroma/admin/config/descriptions" do