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,
type: :string,
description:
"A message that will be sent to newly registered users",
description: "A message that will be sent to newly registered users",
suggestions: [
"Hi, @username! Welcome on board!"
]
@ -3552,13 +3551,15 @@ config :pleroma, :config_description, [
key: "name",
label: "Name",
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",
label: "Reference",
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>"}]
]
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
describe "GET /api/pleroma/admin/config/descriptions" do