summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2020-07-22 16:01:55 -0500
committerAlex Gleason <alex@alexgleason.me>2020-07-22 16:11:53 -0500
commitb6488a4db4accc6cda716c5fdfb03f5a30ddf3d4 (patch)
treefc939bbd2c18b9059dd0a17240a8689917e7012c
parentc7a0016f9f4731c58a7989c7ee10e19d3f90d2eb (diff)
Update linkify migration tests to use config from ConfigDB
-rw-r--r--test/formatter_test.exs1
-rw-r--r--test/migrations/20200716195806_autolinker_to_linkify_test.exs16
-rw-r--r--test/migrations/20200722185515_fix_malformed_formatter_config_test.exs12
3 files changed, 19 insertions, 10 deletions
diff --git a/test/formatter_test.exs b/test/formatter_test.exs
index 8713ab9c2..f066bd50a 100644
--- a/test/formatter_test.exs
+++ b/test/formatter_test.exs
@@ -10,6 +10,7 @@ defmodule Pleroma.FormatterTest do
import Pleroma.Factory
setup_all do
+ clear_config(Pleroma.Formatter)
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok
end
diff --git a/test/migrations/20200716195806_autolinker_to_linkify_test.exs b/test/migrations/20200716195806_autolinker_to_linkify_test.exs
index 063dab0f7..250d11c61 100644
--- a/test/migrations/20200716195806_autolinker_to_linkify_test.exs
+++ b/test/migrations/20200716195806_autolinker_to_linkify_test.exs
@@ -1,9 +1,10 @@
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
@@ -13,7 +14,7 @@ defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
class: false,
strip_prefix: false,
new_window: false,
- rel: "ugc"
+ rel: "testing"
]
insert(:config, group: :auto_linker, key: :opts, value: autolinker_opts)
@@ -28,17 +29,20 @@ defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
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
@@ -48,14 +52,14 @@ defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest 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
]
diff --git a/test/migrations/20200722185515_fix_malformed_formatter_config_test.exs b/test/migrations/20200722185515_fix_malformed_formatter_config_test.exs
index 9e8f997a0..d3490478e 100644
--- a/test/migrations/20200722185515_fix_malformed_formatter_config_test.exs
+++ b/test/migrations/20200722185515_fix_malformed_formatter_config_test.exs
@@ -1,9 +1,10 @@
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
@@ -11,7 +12,7 @@ defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
class: false,
extra: true,
new_window: false,
- rel: "ugc",
+ rel: "F",
strip_prefix: false
}
@@ -25,17 +26,20 @@ defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
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