changes after rebase

This commit is contained in:
Alexander Strizhakov 2020-08-16 21:01:38 +03:00
commit c4c5caedd8
No known key found for this signature in database
GPG key ID: 022896A53AEF1381
17 changed files with 2 additions and 3 deletions

View file

@ -1,72 +0,0 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
use Pleroma.DataCase
import Pleroma.Factory
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
autolinker_opts = [
extra: true,
validate_tld: true,
class: false,
strip_prefix: false,
new_window: false,
rel: "testing"
]
insert(:config, group: :auto_linker, key: :opts, value: autolinker_opts)
migration.change()
assert nil == ConfigDB.get_by_params(%{group: :auto_linker, key: :opts})
%{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
assert new_opts == [
class: false,
extra: true,
new_window: false,
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=\"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
old_opts = [
extra: true,
validate_tld: true,
class: false,
strip_prefix: false,
new_window: false,
rel: "qqq"
]
expected_opts = [
class: false,
extra: true,
new_window: false,
rel: "qqq",
strip_prefix: false
]
assert migration.transform_opts(old_opts) == expected_opts
end
end

View file

@ -1,70 +0,0 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
use Pleroma.DataCase
import Pleroma.Factory
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
incorrect_opts = %{
class: false,
extra: true,
new_window: false,
rel: "F",
strip_prefix: false
}
insert(:config, group: :pleroma, key: Pleroma.Formatter, value: incorrect_opts)
assert :ok == migration.change()
%{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
assert new_opts == [
class: false,
extra: true,
new_window: false,
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=\"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
opts = [
class: false,
extra: true,
new_window: false,
rel: "ugc",
strip_prefix: false
]
insert(:config, group: :pleroma, key: Pleroma.Formatter, value: opts)
assert :skipped == migration.change()
%{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
assert new_opts == opts
end
test "change/0 skips if Pleroma.Formatter is empty", %{migration: migration} do
assert :skipped == migration.change()
end
end

View file

@ -1,144 +0,0 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.MoveWelcomeSettingsTest do
use Pleroma.DataCase
import Pleroma.Factory
import Pleroma.Tests.Helpers
alias Pleroma.ConfigDB
setup_all do: require_migration("20200724133313_move_welcome_settings")
describe "up/0" do
test "converts welcome settings", %{migration: migration} do
insert(:config,
group: :pleroma,
key: :instance,
value: [
welcome_message: "Test message",
welcome_user_nickname: "jimm",
name: "Pleroma"
]
)
migration.up()
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
welcome_config = ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
assert instance_config.value == [name: "Pleroma"]
assert welcome_config.value == [
direct_message: %{
enabled: true,
message: "Test message",
sender_nickname: "jimm"
},
email: %{
enabled: false,
html: "Welcome to <%= instance_name %>",
sender: nil,
subject: "Welcome to <%= instance_name %>",
text: "Welcome to <%= instance_name %>"
}
]
end
test "does nothing when message empty", %{migration: migration} do
insert(:config,
group: :pleroma,
key: :instance,
value: [
welcome_message: "",
welcome_user_nickname: "jimm",
name: "Pleroma"
]
)
migration.up()
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
assert instance_config.value == [name: "Pleroma"]
end
test "does nothing when welcome_message not set", %{migration: migration} do
insert(:config,
group: :pleroma,
key: :instance,
value: [welcome_user_nickname: "jimm", name: "Pleroma"]
)
migration.up()
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
assert instance_config.value == [name: "Pleroma"]
end
end
describe "down/0" do
test "revert new settings to old when instance setting not exists", %{migration: migration} do
insert(:config,
group: :pleroma,
key: :welcome,
value: [
direct_message: %{
enabled: true,
message: "Test message",
sender_nickname: "jimm"
},
email: %{
enabled: false,
html: "Welcome to <%= instance_name %>",
sender: nil,
subject: "Welcome to <%= instance_name %>",
text: "Welcome to <%= instance_name %>"
}
]
)
migration.down()
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
assert instance_config.value == [
welcome_user_nickname: "jimm",
welcome_message: "Test message"
]
end
test "revert new settings to old when instance setting exists", %{migration: migration} do
insert(:config, group: :pleroma, key: :instance, value: [name: "Pleroma App"])
insert(:config,
group: :pleroma,
key: :welcome,
value: [
direct_message: %{
enabled: true,
message: "Test message",
sender_nickname: "jimm"
},
email: %{
enabled: false,
html: "Welcome to <%= instance_name %>",
sender: nil,
subject: "Welcome to <%= instance_name %>",
text: "Welcome to <%= instance_name %>"
}
]
)
migration.down()
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
assert instance_config.value == [
name: "Pleroma App",
welcome_user_nickname: "jimm",
welcome_message: "Test message"
]
end
end
end

View file

@ -1,28 +0,0 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Repo.Migrations.FixLegacyTagsTest do
alias Pleroma.User
use Pleroma.DataCase
import Pleroma.Factory
import Pleroma.Tests.Helpers
setup_all do: require_migration("20200802170532_fix_legacy_tags")
test "change/0 converts legacy user tags into correct values", %{migration: migration} do
user = insert(:user, tags: ["force_nsfw", "force_unlisted", "verified"])
user2 = insert(:user)
assert :ok == migration.change()
fixed_user = User.get_by_id(user.id)
fixed_user2 = User.get_by_id(user2.id)
assert fixed_user.tags == ["mrf_tag:media-force-nsfw", "mrf_tag:force-unlisted", "verified"]
assert fixed_user2.tags == []
# user2 should not have been updated
assert fixed_user2.updated_at == fixed_user2.inserted_at
end
end