Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Emails.MailerTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Emails.Mailer
  7. import Swoosh.TestAssertions
  8. @email %Swoosh.Email{
  9. from: {"Pleroma", "noreply@example.com"},
  10. html_body: "Test email",
  11. subject: "Pleroma test email",
  12. to: [{"Test User", "user1@example.com"}]
  13. }
  14. clear_config([Pleroma.Emails.Mailer, :enabled])
  15. test "not send email when mailer is disabled" do
  16. Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
  17. Mailer.deliver(@email)
  18. refute_email_sent(
  19. from: {"Pleroma", "noreply@example.com"},
  20. to: [{"Test User", "user1@example.com"}],
  21. html_body: "Test email",
  22. subject: "Pleroma test email"
  23. )
  24. end
  25. test "send email" do
  26. Mailer.deliver(@email)
  27. assert_email_sent(
  28. from: {"Pleroma", "noreply@example.com"},
  29. to: [{"Test User", "user1@example.com"}],
  30. html_body: "Test email",
  31. subject: "Pleroma test email"
  32. )
  33. end
  34. test "perform" do
  35. Mailer.perform(:deliver_async, @email, [])
  36. assert_email_sent(
  37. from: {"Pleroma", "noreply@example.com"},
  38. to: [{"Test User", "user1@example.com"}],
  39. html_body: "Test email",
  40. subject: "Pleroma test email"
  41. )
  42. end
  43. end