X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fuser_test.exs;h=b07fed42bac84b2eb9b0830887e0ad4f74893f4c;hb=bb49d8f5a0dbbad65a8f65a28cc2d0847b518067;hp=158f98e6600488ba5d693704e784a9c0eacb1884;hpb=6fab5fe7f892b5a9cf4d605b079e544583f0ce73;p=akkoma
diff --git a/test/user_test.exs b/test/user_test.exs
index 158f98e66..b07fed42b 100644
--- a/test/user_test.exs
+++ b/test/user_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.UserTest do
@@ -297,15 +297,7 @@ defmodule Pleroma.UserTest do
end
describe "unfollow/2" do
- setup do
- setting = Pleroma.Config.get([:instance, :external_user_synchronization])
-
- on_exit(fn ->
- Pleroma.Config.put([:instance, :external_user_synchronization], setting)
- end)
-
- :ok
- end
+ clear_config([:instance, :external_user_synchronization])
test "unfollow with syncronizes external user" do
Pleroma.Config.put([:instance, :external_user_synchronization], true)
@@ -383,6 +375,7 @@ defmodule Pleroma.UserTest do
password_confirmation: "test",
email: "email@example.com"
}
+
clear_config([:instance, :autofollowed_nicknames])
clear_config([:instance, :welcome_message])
clear_config([:instance, :welcome_user_nickname])
@@ -419,7 +412,11 @@ defmodule Pleroma.UserTest do
assert activity.actor == welcome_user.ap_id
end
- test "it requires an email, name, nickname and password, bio is optional" do
+ clear_config([:instance, :account_activation_required])
+
+ test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do
+ Pleroma.Config.put([:instance, :account_activation_required], true)
+
@full_user_data
|> Map.keys()
|> Enum.each(fn key ->
@@ -430,6 +427,19 @@ defmodule Pleroma.UserTest do
end)
end
+ test "it requires an name, nickname and password, bio and email are optional when account_activation_required is disabled" do
+ Pleroma.Config.put([:instance, :account_activation_required], false)
+
+ @full_user_data
+ |> Map.keys()
+ |> Enum.each(fn key ->
+ params = Map.delete(@full_user_data, key)
+ changeset = User.register_changeset(%User{}, params)
+
+ assert if key in [:bio, :email], do: changeset.valid?, else: not changeset.valid?
+ end)
+ end
+
test "it restricts certain nicknames" do
[restricted_name | _] = Pleroma.Config.get([User, :restricted_nicknames])
@@ -585,7 +595,7 @@ defmodule Pleroma.UserTest do
user = insert(:user)
assert User.ap_id(user) ==
- Pleroma.Web.Router.Helpers.feed_url(
+ Pleroma.Web.Router.Helpers.user_feed_url(
Pleroma.Web.Endpoint,
:feed_redirect,
user.nickname
@@ -596,7 +606,7 @@ defmodule Pleroma.UserTest do
user = insert(:user)
assert User.ap_followers(user) ==
- Pleroma.Web.Router.Helpers.feed_url(
+ Pleroma.Web.Router.Helpers.user_feed_url(
Pleroma.Web.Endpoint,
:feed_redirect,
user.nickname
@@ -1754,17 +1764,14 @@ defmodule Pleroma.UserTest do
describe "get_cached_by_nickname_or_id" do
setup do
- limit_to_local_content = Pleroma.Config.get([:instance, :limit_to_local_content])
local_user = insert(:user)
remote_user = insert(:user, nickname: "nickname@example.com", local: false)
- on_exit(fn ->
- Pleroma.Config.put([:instance, :limit_to_local_content], limit_to_local_content)
- end)
-
[local_user: local_user, remote_user: remote_user]
end
+ clear_config([:instance, :limit_to_local_content])
+
test "allows getting remote users by id no matter what :limit_to_local_content is set to", %{
remote_user: remote_user
} do