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.

50 lines
1.9KB

  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.AdminEmailTest do
  5. use Pleroma.DataCase
  6. import Pleroma.Factory
  7. alias Pleroma.Emails.AdminEmail
  8. alias Pleroma.Web.Router.Helpers
  9. test "build report email" do
  10. config = Pleroma.Config.get(:instance)
  11. to_user = insert(:user)
  12. reporter = insert(:user)
  13. account = insert(:user)
  14. res =
  15. AdminEmail.report(to_user, reporter, account, [%{name: "Test", id: "12"}], "Test comment")
  16. status_url = Helpers.o_status_url(Pleroma.Web.Endpoint, :notice, "12")
  17. reporter_url = Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, reporter.id)
  18. account_url = Helpers.user_feed_url(Pleroma.Web.Endpoint, :feed_redirect, account.id)
  19. assert res.to == [{to_user.name, to_user.email}]
  20. assert res.from == {config[:name], config[:notify_email]}
  21. assert res.subject == "#{config[:name]} Report"
  22. assert res.html_body ==
  23. "<p>Reported by: <a href=\"#{reporter_url}\">#{reporter.nickname}</a></p>\n<p>Reported Account: <a href=\"#{
  24. account_url
  25. }\">#{account.nickname}</a></p>\n<p>Comment: Test comment\n<p> Statuses:\n <ul>\n <li><a href=\"#{
  26. status_url
  27. }\">#{status_url}</li>\n </ul>\n</p>\n\n<p>\n<a href=\"http://localhost:4001/pleroma/admin/#/reports/index\">View Reports in AdminFE</a>\n"
  28. end
  29. test "it works when the reporter is a remote user without email" do
  30. config = Pleroma.Config.get(:instance)
  31. to_user = insert(:user)
  32. reporter = insert(:user, email: nil, local: false)
  33. account = insert(:user)
  34. res =
  35. AdminEmail.report(to_user, reporter, account, [%{name: "Test", id: "12"}], "Test comment")
  36. assert res.to == [{to_user.name, to_user.email}]
  37. assert res.from == {config[:name], config[:notify_email]}
  38. end
  39. end