Merge branch 'issue/2069' into 'develop'
[akkoma] / test / pleroma / user / welcome_message_test.exs
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
5 defmodule Pleroma.User.WelcomeMessageTest do
6 use Pleroma.DataCase
7
8 alias Pleroma.Config
9 alias Pleroma.User.WelcomeMessage
10
11 import Pleroma.Factory
12
13 setup do: clear_config([:welcome])
14
15 describe "post_message/1" do
16 test "send a direct welcome message" do
17 welcome_user = insert(:user)
18 user = insert(:user, name: "Jimm")
19
20 Config.put([:welcome, :direct_message, :enabled], true)
21 Config.put([:welcome, :direct_message, :sender_nickname], welcome_user.nickname)
22
23 Config.put(
24 [:welcome, :direct_message, :message],
25 "Hello. Welcome to Pleroma"
26 )
27
28 {:ok, %Pleroma.Activity{} = activity} = WelcomeMessage.post_message(user)
29 assert user.ap_id in activity.recipients
30 assert activity.data["directMessage"] == true
31 assert Pleroma.Object.normalize(activity).data["content"] =~ "Hello. Welcome to Pleroma"
32 end
33 end
34 end