1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.MoveWelcomeSettingsTest do
8 import Pleroma.Tests.Helpers
11 setup_all do: require_migration("20200724133313_move_welcome_settings")
14 test "converts welcome settings", %{migration: migration} do
19 welcome_message: "Test message",
20 welcome_user_nickname: "jimm",
26 instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
27 welcome_config = ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
29 assert instance_config.value == [name: "Pleroma"]
31 assert welcome_config.value == [
34 message: "Test message",
35 sender_nickname: "jimm"
39 html: "Welcome to <%= instance_name %>",
41 subject: "Welcome to <%= instance_name %>",
42 text: "Welcome to <%= instance_name %>"
47 test "does nothing when message empty", %{migration: migration} do
53 welcome_user_nickname: "jimm",
59 instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
60 refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
61 assert instance_config.value == [name: "Pleroma"]
64 test "does nothing when welcome_message not set", %{migration: migration} do
68 value: [welcome_user_nickname: "jimm", name: "Pleroma"]
72 instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
73 refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
74 assert instance_config.value == [name: "Pleroma"]
79 test "revert new settings to old when instance setting not exists", %{migration: migration} do
86 message: "Test message",
87 sender_nickname: "jimm"
91 html: "Welcome to <%= instance_name %>",
93 subject: "Welcome to <%= instance_name %>",
94 text: "Welcome to <%= instance_name %>"
101 refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
102 instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
104 assert instance_config.value == [
105 welcome_user_nickname: "jimm",
106 welcome_message: "Test message"
110 test "revert new settings to old when instance setting exists", %{migration: migration} do
111 insert(:config, group: :pleroma, key: :instance, value: [name: "Pleroma App"])
119 message: "Test message",
120 sender_nickname: "jimm"
124 html: "Welcome to <%= instance_name %>",
126 subject: "Welcome to <%= instance_name %>",
127 text: "Welcome to <%= instance_name %>"
134 refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
135 instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
137 assert instance_config.value == [
139 welcome_user_nickname: "jimm",
140 welcome_message: "Test message"