1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.User.WelcomeEmailTest do
9 alias Pleroma.Tests.ObanHelpers
10 alias Pleroma.User.WelcomeEmail
12 import Pleroma.Factory
13 import Swoosh.TestAssertions
15 setup do: clear_config([:welcome])
17 describe "send_email/1" do
18 test "send a welcome email" do
19 user = insert(:user, name: "Jimm")
21 Config.put([:welcome, :email, :enabled], true)
22 Config.put([:welcome, :email, :sender], "welcome@pleroma.app")
25 [:welcome, :email, :subject],
26 "Hello, welcome to pleroma: <%= instance_name %>"
30 [:welcome, :email, :html],
31 "<h1>Hello <%= user.name %>.</h1> <p>Welcome to <%= instance_name %></p>"
34 instance_name = Config.get([:instance, :name])
36 {:ok, _job} = WelcomeEmail.send_email(user)
38 ObanHelpers.perform_all()
41 from: {instance_name, "welcome@pleroma.app"},
42 to: {user.name, user.email},
43 subject: "Hello, welcome to pleroma: #{instance_name}",
44 html_body: "<h1>Hello #{user.name}.</h1> <p>Welcome to #{instance_name}</p>"
47 Config.put([:welcome, :email, :sender], {"Pleroma App", "welcome@pleroma.app"})
49 {:ok, _job} = WelcomeEmail.send_email(user)
51 ObanHelpers.perform_all()
54 from: {"Pleroma App", "welcome@pleroma.app"},
55 to: {user.name, user.email},
56 subject: "Hello, welcome to pleroma: #{instance_name}",
57 html_body: "<h1>Hello #{user.name}.</h1> <p>Welcome to #{instance_name}</p>"