defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
use Pleroma.DataCase
import Pleroma.Factory
- import Pleroma.Tests.Helpers, only: [require_migration: 1]
+ import Pleroma.Tests.Helpers
alias Pleroma.ConfigDB
+ setup do: clear_config(Pleroma.Formatter)
setup_all do: require_migration("20200716195806_autolinker_to_linkify")
test "change/0 converts auto_linker opts for Pleroma.Formatter", %{migration: migration} do
class: false,
strip_prefix: false,
new_window: false,
- rel: "ugc"
+ rel: "testing"
]
insert(:config, group: :auto_linker, key: :opts, value: autolinker_opts)
class: false,
extra: true,
new_window: false,
- rel: "ugc",
+ rel: "testing",
strip_prefix: false
]
+ Pleroma.Config.put(Pleroma.Formatter, new_opts)
+ assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
+
{text, _mentions, []} =
Pleroma.Formatter.linkify(
"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
)
assert text ==
- "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"ugc\">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???"
+ "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"testing\">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???"
end
test "transform_opts/1 returns a list of compatible opts", %{migration: migration} do
class: false,
strip_prefix: false,
new_window: false,
- rel: "ugc"
+ rel: "qqq"
]
expected_opts = [
class: false,
extra: true,
new_window: false,
- rel: "ugc",
+ rel: "qqq",
strip_prefix: false
]
defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
use Pleroma.DataCase
import Pleroma.Factory
- import Pleroma.Tests.Helpers, only: [require_migration: 1]
+ import Pleroma.Tests.Helpers
alias Pleroma.ConfigDB
+ setup do: clear_config(Pleroma.Formatter)
setup_all do: require_migration("20200722185515_fix_malformed_formatter_config")
test "change/0 converts a map into a list", %{migration: migration} do
class: false,
extra: true,
new_window: false,
- rel: "ugc",
+ rel: "F",
strip_prefix: false
}
class: false,
extra: true,
new_window: false,
- rel: "ugc",
+ rel: "F",
strip_prefix: false
]
+ Pleroma.Config.put(Pleroma.Formatter, new_opts)
+ assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
+
{text, _mentions, []} =
Pleroma.Formatter.linkify(
"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
)
assert text ==
- "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"ugc\">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???"
+ "<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???"
end
test "change/0 skips if Pleroma.Formatter config is already a list", %{migration: migration} do