logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

user_email_test.exs (1828B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Emails.UserEmailTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Emails.UserEmail
  7. alias Pleroma.Web.Endpoint
  8. alias Pleroma.Web.Router
  9. import Pleroma.Factory
  10. test "build password reset email" do
  11. config = Pleroma.Config.get(:instance)
  12. user = insert(:user)
  13. email = UserEmail.password_reset_email(user, "test_token")
  14. assert email.from == {config[:name], config[:notify_email]}
  15. assert email.to == [{user.name, user.email}]
  16. assert email.subject == "Password reset"
  17. assert email.html_body =~ Router.Helpers.reset_password_url(Endpoint, :reset, "test_token")
  18. end
  19. test "build user invitation email" do
  20. config = Pleroma.Config.get(:instance)
  21. user = insert(:user)
  22. token = %Pleroma.UserInviteToken{token: "test-token"}
  23. email = UserEmail.user_invitation_email(user, token, "test@test.com", "Jonh")
  24. assert email.from == {config[:name], config[:notify_email]}
  25. assert email.subject == "Invitation to Pleroma"
  26. assert email.to == [{"Jonh", "test@test.com"}]
  27. assert email.html_body =~
  28. Router.Helpers.redirect_url(Endpoint, :registration_page, token.token)
  29. end
  30. test "build account confirmation email" do
  31. config = Pleroma.Config.get(:instance)
  32. user = insert(:user, confirmation_token: "conf-token")
  33. email = UserEmail.account_confirmation_email(user)
  34. assert email.from == {config[:name], config[:notify_email]}
  35. assert email.to == [{user.name, user.email}]
  36. assert email.subject == "#{config[:name]} account confirmation"
  37. assert email.html_body =~
  38. Router.Helpers.confirm_email_url(Endpoint, :confirm_email, user.id, "conf-token")
  39. end
  40. end