2019-07-10 07:34:21 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 23:44:49 +01:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-07-10 07:34:21 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Emails.UserEmailTest do
|
2020-12-21 12:21:40 +01:00
|
|
|
use Pleroma.DataCase, async: true
|
2019-07-10 07:34:21 +02:00
|
|
|
|
|
|
|
alias Pleroma.Emails.UserEmail
|
|
|
|
alias Pleroma.Web.Endpoint
|
|
|
|
alias Pleroma.Web.Router
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
test "build password reset email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
|
|
|
user = insert(:user)
|
|
|
|
email = UserEmail.password_reset_email(user, "test_token")
|
|
|
|
assert email.from == {config[:name], config[:notify_email]}
|
|
|
|
assert email.to == [{user.name, user.email}]
|
|
|
|
assert email.subject == "Password reset"
|
|
|
|
assert email.html_body =~ Router.Helpers.reset_password_url(Endpoint, :reset, "test_token")
|
|
|
|
end
|
|
|
|
|
|
|
|
test "build user invitation email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
|
|
|
user = insert(:user)
|
|
|
|
token = %Pleroma.UserInviteToken{token: "test-token"}
|
|
|
|
email = UserEmail.user_invitation_email(user, token, "test@test.com", "Jonh")
|
|
|
|
assert email.from == {config[:name], config[:notify_email]}
|
|
|
|
assert email.subject == "Invitation to Pleroma"
|
|
|
|
assert email.to == [{"Jonh", "test@test.com"}]
|
|
|
|
|
|
|
|
assert email.html_body =~
|
|
|
|
Router.Helpers.redirect_url(Endpoint, :registration_page, token.token)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "build account confirmation email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
2019-10-16 20:59:21 +02:00
|
|
|
user = insert(:user, confirmation_token: "conf-token")
|
2019-07-10 07:34:21 +02:00
|
|
|
email = UserEmail.account_confirmation_email(user)
|
|
|
|
assert email.from == {config[:name], config[:notify_email]}
|
|
|
|
assert email.to == [{user.name, user.email}]
|
|
|
|
assert email.subject == "#{config[:name]} account confirmation"
|
|
|
|
|
|
|
|
assert email.html_body =~
|
|
|
|
Router.Helpers.confirm_email_url(Endpoint, :confirm_email, user.id, "conf-token")
|
|
|
|
end
|
2020-10-12 03:50:09 +02:00
|
|
|
|
|
|
|
test "build approval pending email" do
|
|
|
|
config = Pleroma.Config.get(:instance)
|
|
|
|
user = insert(:user)
|
|
|
|
email = UserEmail.approval_pending_email(user)
|
|
|
|
|
|
|
|
assert email.from == {config[:name], config[:notify_email]}
|
|
|
|
assert email.to == [{user.name, user.email}]
|
|
|
|
assert email.subject == "Your account is awaiting approval"
|
|
|
|
assert email.html_body =~ "Awaiting Approval"
|
|
|
|
end
|
2019-07-10 07:34:21 +02:00
|
|
|
end
|