1 defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
4 import Pleroma.Tests.Helpers
7 setup do: clear_config(Pleroma.Formatter)
8 setup_all do: require_migration("20200722185515_fix_malformed_formatter_config")
10 test "change/0 converts a map into a list", %{migration: migration} do
19 insert(:config, group: :pleroma, key: Pleroma.Formatter, value: incorrect_opts)
21 assert :ok == migration.change()
23 %{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
33 Pleroma.Config.put(Pleroma.Formatter, new_opts)
34 assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
36 {text, _mentions, []} =
37 Pleroma.Formatter.linkify(
38 "https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
42 "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"F\">https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7</a>\n\nOmg will COVID finally end Black Friday???"
45 test "change/0 skips if Pleroma.Formatter config is already a list", %{migration: migration} do
54 insert(:config, group: :pleroma, key: Pleroma.Formatter, value: opts)
56 assert :skipped == migration.change()
58 %{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
60 assert new_opts == opts
63 test "change/0 skips if Pleroma.Formatter is empty", %{migration: migration} do
64 assert :skipped == migration.change()