X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fuser_test.exs;h=bff337d3e48bacf56991f2c4e4bbe7ed07143fc8;hb=142bf0957c64f76b9b511200544b1ccbcef5ba16;hp=c345e43e9168a475bb291013208a16b48bf3f1b1;hpb=7722e5a67a46304f3ae0e37f674a44ca9268be5e;p=akkoma
diff --git a/test/user_test.exs b/test/user_test.exs
index c345e43e9..bff337d3e 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
@@ -17,15 +17,52 @@ defmodule Pleroma.UserTest do
import Mock
import Pleroma.Factory
+ import ExUnit.CaptureLog
setup_all do
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
:ok
end
- clear_config([:instance, :account_activation_required])
+ setup do: clear_config([:instance, :account_activation_required])
describe "service actors" do
+ test "returns updated invisible actor" do
+ uri = "#{Pleroma.Web.Endpoint.url()}/relay"
+ followers_uri = "#{uri}/followers"
+
+ insert(
+ :user,
+ %{
+ nickname: "relay",
+ invisible: false,
+ local: true,
+ ap_id: uri,
+ follower_address: followers_uri
+ }
+ )
+
+ actor = User.get_or_create_service_actor_by_ap_id(uri, "relay")
+ assert actor.invisible
+ end
+
+ test "returns relay user" do
+ uri = "#{Pleroma.Web.Endpoint.url()}/relay"
+ followers_uri = "#{uri}/followers"
+
+ assert %User{
+ nickname: "relay",
+ invisible: true,
+ local: true,
+ ap_id: ^uri,
+ follower_address: ^followers_uri
+ } = User.get_or_create_service_actor_by_ap_id(uri, "relay")
+
+ assert capture_log(fn ->
+ refute User.get_or_create_service_actor_by_ap_id("/relay", "relay")
+ end) =~ "Cannot create service actor:"
+ end
+
test "returns invisible actor" do
uri = "#{Pleroma.Web.Endpoint.url()}/internal/fetch-test"
followers_uri = "#{uri}/followers"
@@ -44,6 +81,56 @@ defmodule Pleroma.UserTest do
end
end
+ describe "AP ID user relationships" do
+ setup do
+ {:ok, user: insert(:user)}
+ end
+
+ test "outgoing_relationships_ap_ids/1", %{user: user} do
+ rel_types = [:block, :mute, :notification_mute, :reblog_mute, :inverse_subscription]
+
+ ap_ids_by_rel =
+ Enum.into(
+ rel_types,
+ %{},
+ fn rel_type ->
+ rel_records =
+ insert_list(2, :user_relationship, %{source: user, relationship_type: rel_type})
+
+ ap_ids = Enum.map(rel_records, fn rr -> Repo.preload(rr, :target).target.ap_id end)
+ {rel_type, Enum.sort(ap_ids)}
+ end
+ )
+
+ assert ap_ids_by_rel[:block] == Enum.sort(User.blocked_users_ap_ids(user))
+ assert ap_ids_by_rel[:block] == Enum.sort(Enum.map(User.blocked_users(user), & &1.ap_id))
+
+ assert ap_ids_by_rel[:mute] == Enum.sort(User.muted_users_ap_ids(user))
+ assert ap_ids_by_rel[:mute] == Enum.sort(Enum.map(User.muted_users(user), & &1.ap_id))
+
+ assert ap_ids_by_rel[:notification_mute] ==
+ Enum.sort(User.notification_muted_users_ap_ids(user))
+
+ assert ap_ids_by_rel[:notification_mute] ==
+ Enum.sort(Enum.map(User.notification_muted_users(user), & &1.ap_id))
+
+ assert ap_ids_by_rel[:reblog_mute] == Enum.sort(User.reblog_muted_users_ap_ids(user))
+
+ assert ap_ids_by_rel[:reblog_mute] ==
+ Enum.sort(Enum.map(User.reblog_muted_users(user), & &1.ap_id))
+
+ assert ap_ids_by_rel[:inverse_subscription] == Enum.sort(User.subscriber_users_ap_ids(user))
+
+ assert ap_ids_by_rel[:inverse_subscription] ==
+ Enum.sort(Enum.map(User.subscriber_users(user), & &1.ap_id))
+
+ outgoing_relationships_ap_ids = User.outgoing_relationships_ap_ids(user, rel_types)
+
+ assert ap_ids_by_rel ==
+ Enum.into(outgoing_relationships_ap_ids, %{}, fn {k, v} -> {k, Enum.sort(v)} end)
+ end
+ end
+
describe "when tags are nil" do
test "tagging a user" do
user = insert(:user, %{tags: nil})
@@ -107,7 +194,8 @@ defmodule Pleroma.UserTest do
CommonAPI.follow(pending_follower, locked)
CommonAPI.follow(pending_follower, locked)
CommonAPI.follow(accepted_follower, locked)
- Pleroma.FollowingRelationship.update(accepted_follower, locked, "accept")
+
+ Pleroma.FollowingRelationship.update(accepted_follower, locked, :follow_accept)
assert [^pending_follower] = User.get_follow_requests(locked)
end
@@ -119,7 +207,7 @@ defmodule Pleroma.UserTest do
CommonAPI.follow(follower, followed)
assert [_activity] = User.get_follow_requests(followed)
- {:ok, _follower} = User.block(followed, follower)
+ {:ok, _user_relationship} = User.block(followed, follower)
assert [] = User.get_follow_requests(followed)
end
@@ -132,8 +220,8 @@ defmodule Pleroma.UserTest do
not_followed = insert(:user)
reverse_blocked = insert(:user)
- {:ok, user} = User.block(user, blocked)
- {:ok, reverse_blocked} = User.block(reverse_blocked, user)
+ {:ok, _user_relationship} = User.block(user, blocked)
+ {:ok, _user_relationship} = User.block(reverse_blocked, user)
{:ok, user} = User.follow(user, followed_zero)
@@ -186,7 +274,7 @@ defmodule Pleroma.UserTest do
blocker = insert(:user)
blockee = insert(:user)
- {:ok, blocker} = User.block(blocker, blockee)
+ {:ok, _user_relationship} = User.block(blocker, blockee)
{:error, _} = User.follow(blockee, blocker)
end
@@ -195,7 +283,7 @@ defmodule Pleroma.UserTest do
blocker = insert(:user)
blocked = insert(:user)
- {:ok, blocker} = User.block(blocker, blocked)
+ {:ok, _user_relationship} = User.block(blocker, blocked)
{:error, _} = User.subscribe(blocked, blocker)
end
@@ -210,15 +298,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
+ setup do: clear_config([:instance, :external_user_synchronization])
test "unfollow with syncronizes external user" do
Pleroma.Config.put([:instance, :external_user_synchronization], true)
@@ -240,7 +320,7 @@ defmodule Pleroma.UserTest do
following_address: "http://localhost:4001/users/fuser2/following"
})
- {:ok, user} = User.follow(user, followed, "accept")
+ {:ok, user} = User.follow(user, followed, :follow_accept)
{:ok, user, _activity} = User.unfollow(user, followed)
@@ -253,7 +333,7 @@ defmodule Pleroma.UserTest do
followed = insert(:user)
user = insert(:user)
- {:ok, user} = User.follow(user, followed, "accept")
+ {:ok, user} = User.follow(user, followed, :follow_accept)
assert User.following(user) == [user.follower_address, followed.follower_address]
@@ -274,7 +354,7 @@ defmodule Pleroma.UserTest do
test "test if a user is following another user" do
followed = insert(:user)
user = insert(:user)
- User.follow(user, followed, "accept")
+ User.follow(user, followed, :follow_accept)
assert User.following?(user, followed)
refute User.following?(followed, user)
@@ -296,9 +376,9 @@ 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])
+ setup do: clear_config([:instance, :autofollowed_nicknames])
+ setup do: clear_config([:instance, :welcome_message])
+ setup do: clear_config([:instance, :welcome_user_nickname])
test "it autofollows accounts that are set for it" do
user = insert(:user)
@@ -332,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
+ setup 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 ->
@@ -343,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])
@@ -378,10 +475,7 @@ defmodule Pleroma.UserTest do
password_confirmation: "test",
email: "email@example.com"
}
-
- clear_config([:instance, :account_activation_required]) do
- Pleroma.Config.put([:instance, :account_activation_required], true)
- end
+ setup do: clear_config([:instance, :account_activation_required], true)
test "it creates unconfirmed user" do
changeset = User.register_changeset(%User{}, @full_user_data)
@@ -488,7 +582,7 @@ defmodule Pleroma.UserTest do
{:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin")
- assert user.source_data["endpoints"]
+ assert user.inbox
refute user.last_refreshed_at == orig_user.last_refreshed_at
end
@@ -498,7 +592,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
@@ -509,14 +603,14 @@ 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
) <> "/followers"
end
- describe "remote user creation changeset" do
+ describe "remote user changeset" do
@valid_remote %{
bio: "hello",
name: "Someone",
@@ -524,33 +618,32 @@ defmodule Pleroma.UserTest do
ap_id: "http...",
avatar: %{some: "avatar"}
}
-
- clear_config([:instance, :user_bio_length])
- clear_config([:instance, :user_name_length])
+ setup do: clear_config([:instance, :user_bio_length])
+ setup do: clear_config([:instance, :user_name_length])
test "it confirms validity" do
- cs = User.remote_user_creation(@valid_remote)
+ cs = User.remote_user_changeset(@valid_remote)
assert cs.valid?
end
test "it sets the follower_adress" do
- cs = User.remote_user_creation(@valid_remote)
+ cs = User.remote_user_changeset(@valid_remote)
# remote users get a fake local follower address
assert cs.changes.follower_address ==
User.ap_followers(%User{nickname: @valid_remote[:nickname]})
end
test "it enforces the fqn format for nicknames" do
- cs = User.remote_user_creation(%{@valid_remote | nickname: "bla"})
+ cs = User.remote_user_changeset(%{@valid_remote | nickname: "bla"})
assert Ecto.Changeset.get_field(cs, :local) == false
assert cs.changes.avatar
refute cs.valid?
end
test "it has required fields" do
- [:name, :ap_id]
+ [:ap_id]
|> Enum.each(fn field ->
- cs = User.remote_user_creation(Map.delete(@valid_remote, field))
+ cs = User.remote_user_changeset(Map.delete(@valid_remote, field))
refute cs.valid?
end)
end
@@ -663,8 +756,8 @@ defmodule Pleroma.UserTest do
]
{:ok, job} = User.follow_import(user1, identifiers)
- result = ObanHelpers.perform(job)
+ assert {:ok, result} = ObanHelpers.perform(job)
assert is_list(result)
assert result == [user2, user3]
end
@@ -678,7 +771,7 @@ defmodule Pleroma.UserTest do
refute User.mutes?(user, muted_user)
refute User.muted_notifications?(user, muted_user)
- {:ok, user} = User.mute(user, muted_user)
+ {:ok, _user_relationships} = User.mute(user, muted_user)
assert User.mutes?(user, muted_user)
assert User.muted_notifications?(user, muted_user)
@@ -688,8 +781,8 @@ defmodule Pleroma.UserTest do
user = insert(:user)
muted_user = insert(:user)
- {:ok, user} = User.mute(user, muted_user)
- {:ok, user} = User.unmute(user, muted_user)
+ {:ok, _user_relationships} = User.mute(user, muted_user)
+ {:ok, _user_mute} = User.unmute(user, muted_user)
refute User.mutes?(user, muted_user)
refute User.muted_notifications?(user, muted_user)
@@ -702,7 +795,7 @@ defmodule Pleroma.UserTest do
refute User.mutes?(user, muted_user)
refute User.muted_notifications?(user, muted_user)
- {:ok, user} = User.mute(user, muted_user, false)
+ {:ok, _user_relationships} = User.mute(user, muted_user, false)
assert User.mutes?(user, muted_user)
refute User.muted_notifications?(user, muted_user)
@@ -716,7 +809,7 @@ defmodule Pleroma.UserTest do
refute User.blocks?(user, blocked_user)
- {:ok, user} = User.block(user, blocked_user)
+ {:ok, _user_relationship} = User.block(user, blocked_user)
assert User.blocks?(user, blocked_user)
end
@@ -725,8 +818,8 @@ defmodule Pleroma.UserTest do
user = insert(:user)
blocked_user = insert(:user)
- {:ok, user} = User.block(user, blocked_user)
- {:ok, user} = User.unblock(user, blocked_user)
+ {:ok, _user_relationship} = User.block(user, blocked_user)
+ {:ok, _user_block} = User.unblock(user, blocked_user)
refute User.blocks?(user, blocked_user)
end
@@ -741,7 +834,7 @@ defmodule Pleroma.UserTest do
assert User.following?(blocker, blocked)
assert User.following?(blocked, blocker)
- {:ok, blocker} = User.block(blocker, blocked)
+ {:ok, _user_relationship} = User.block(blocker, blocked)
blocked = User.get_cached_by_id(blocked.id)
assert User.blocks?(blocker, blocked)
@@ -759,7 +852,7 @@ defmodule Pleroma.UserTest do
assert User.following?(blocker, blocked)
refute User.following?(blocked, blocker)
- {:ok, blocker} = User.block(blocker, blocked)
+ {:ok, _user_relationship} = User.block(blocker, blocked)
blocked = User.get_cached_by_id(blocked.id)
assert User.blocks?(blocker, blocked)
@@ -777,7 +870,7 @@ defmodule Pleroma.UserTest do
refute User.following?(blocker, blocked)
assert User.following?(blocked, blocker)
- {:ok, blocker} = User.block(blocker, blocked)
+ {:ok, _user_relationship} = User.block(blocker, blocked)
blocked = User.get_cached_by_id(blocked.id)
assert User.blocks?(blocker, blocked)
@@ -790,12 +883,12 @@ defmodule Pleroma.UserTest do
blocker = insert(:user)
blocked = insert(:user)
- {:ok, blocker} = User.subscribe(blocked, blocker)
+ {:ok, _subscription} = User.subscribe(blocked, blocker)
assert User.subscribed_to?(blocked, blocker)
refute User.subscribed_to?(blocker, blocked)
- {:ok, blocker} = User.block(blocker, blocked)
+ {:ok, _user_relationship} = User.block(blocker, blocked)
assert User.blocks?(blocker, blocked)
refute User.subscribed_to?(blocker, blocked)
@@ -864,6 +957,16 @@ defmodule Pleroma.UserTest do
refute User.blocks?(user, collateral_user)
end
+
+ test "follows take precedence over domain blocks" do
+ user = insert(:user)
+ good_eggo = insert(:user, %{ap_id: "https://meanies.social/user/cuteposter"})
+
+ {:ok, user} = User.block_domain(user, "meanies.social")
+ {:ok, user} = User.follow(user, good_eggo)
+
+ refute User.blocks?(user, good_eggo)
+ end
end
describe "blocks_import" do
@@ -876,14 +979,26 @@ defmodule Pleroma.UserTest do
]
{:ok, job} = User.blocks_import(user1, identifiers)
- result = ObanHelpers.perform(job)
+ assert {:ok, result} = ObanHelpers.perform(job)
assert is_list(result)
assert result == [user2, user3]
end
end
describe "get_recipients_from_activity" do
+ test "works for announces" do
+ actor = insert(:user)
+ user = insert(:user, local: true)
+
+ {:ok, activity} = CommonAPI.post(actor, %{"status" => "hello"})
+ {:ok, announce, _} = CommonAPI.repeat(activity.id, user)
+
+ recipients = User.get_recipients_from_activity(announce)
+
+ assert user in recipients
+ end
+
test "get recipients" do
actor = insert(:user)
user = insert(:user, local: true)
@@ -1009,7 +1124,7 @@ defmodule Pleroma.UserTest do
[user: user]
end
- clear_config([:instance, :federating])
+ setup do: clear_config([:instance, :federating])
test ".delete_user_activities deletes all create activities", %{user: user} do
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
@@ -1020,16 +1135,7 @@ defmodule Pleroma.UserTest do
refute Activity.get_by_id(activity.id)
end
- test "it deletes deactivated user" do
- {:ok, user} = insert(:user, deactivated: true) |> User.set_cache()
-
- {:ok, job} = User.delete(user)
- {:ok, _user} = ObanHelpers.perform(job)
-
- refute User.get_by_id(user.id)
- end
-
- test "it deletes a user, all follow relationships and all activities", %{user: user} do
+ test "it deactivates a user, all follow relationships and all activities", %{user: user} do
follower = insert(:user)
{:ok, follower} = User.follow(follower, user)
@@ -1039,8 +1145,8 @@ defmodule Pleroma.UserTest do
object_two = insert(:note, user: follower)
activity_two = insert(:note_activity, user: follower, note: object_two)
- {:ok, like, _} = CommonAPI.favorite(activity_two.id, user)
- {:ok, like_two, _} = CommonAPI.favorite(activity.id, follower)
+ {:ok, like} = CommonAPI.favorite(user, activity_two.id)
+ {:ok, like_two} = CommonAPI.favorite(follower, activity.id)
{:ok, repeat, _} = CommonAPI.repeat(activity_two.id, user)
{:ok, job} = User.delete(user)
@@ -1049,8 +1155,7 @@ defmodule Pleroma.UserTest do
follower = User.get_cached_by_id(follower.id)
refute User.following?(follower, user)
- refute User.get_by_id(user.id)
- assert {:ok, nil} == Cachex.get(:user_cache, "ap_id:#{user.ap_id}")
+ assert %{deactivated: true} = User.get_by_id(user.id)
user_activities =
user.ap_id
@@ -1096,58 +1201,6 @@ defmodule Pleroma.UserTest do
assert {:ok, _key} = User.get_public_key_for_ap_id("http://mastodon.example.org/users/admin")
end
- describe "insert or update a user from given data" do
- test "with normal data" do
- user = insert(:user, %{nickname: "nick@name.de"})
- data = %{ap_id: user.ap_id <> "xxx", name: user.name, nickname: user.nickname}
-
- assert {:ok, %User{}} = User.insert_or_update_user(data)
- end
-
- test "with overly long fields" do
- current_max_length = Pleroma.Config.get([:instance, :account_field_value_length], 255)
- user = insert(:user, nickname: "nickname@supergood.domain")
-
- data = %{
- ap_id: user.ap_id,
- name: user.name,
- nickname: user.nickname,
- fields: [
- %{"name" => "myfield", "value" => String.duplicate("h", current_max_length + 1)}
- ]
- }
-
- assert {:ok, %User{}} = User.insert_or_update_user(data)
- end
-
- test "with an overly long bio" do
- current_max_length = Pleroma.Config.get([:instance, :user_bio_length], 5000)
- user = insert(:user, nickname: "nickname@supergood.domain")
-
- data = %{
- ap_id: user.ap_id,
- name: user.name,
- nickname: user.nickname,
- bio: String.duplicate("h", current_max_length + 1)
- }
-
- assert {:ok, %User{}} = User.insert_or_update_user(data)
- end
-
- test "with an overly long display name" do
- current_max_length = Pleroma.Config.get([:instance, :user_name_length], 100)
- user = insert(:user, nickname: "nickname@supergood.domain")
-
- data = %{
- ap_id: user.ap_id,
- name: String.duplicate("h", current_max_length + 1),
- nickname: user.nickname
- }
-
- assert {:ok, %User{}} = User.insert_or_update_user(data)
- end
- end
-
describe "per-user rich-text filtering" do
test "html_filter_policy returns default policies, when rich-text is enabled" do
user = insert(:user)
@@ -1189,23 +1242,35 @@ defmodule Pleroma.UserTest do
end
end
- test "auth_active?/1 works correctly" do
- Pleroma.Config.put([:instance, :account_activation_required], true)
+ describe "account_status/1" do
+ setup do: clear_config([:instance, :account_activation_required])
- local_user = insert(:user, local: true, confirmation_pending: true)
- confirmed_user = insert(:user, local: true, confirmation_pending: false)
- remote_user = insert(:user, local: false)
+ test "return confirmation_pending for unconfirm user" do
+ Pleroma.Config.put([:instance, :account_activation_required], true)
+ user = insert(:user, confirmation_pending: true)
+ assert User.account_status(user) == :confirmation_pending
+ end
- refute User.auth_active?(local_user)
- assert User.auth_active?(confirmed_user)
- assert User.auth_active?(remote_user)
+ test "return active for confirmed user" do
+ Pleroma.Config.put([:instance, :account_activation_required], true)
+ user = insert(:user, confirmation_pending: false)
+ assert User.account_status(user) == :active
+ end
- # also shows unactive for deactivated users
+ test "return active for remote user" do
+ user = insert(:user, local: false)
+ assert User.account_status(user) == :active
+ end
- deactivated_but_confirmed =
- insert(:user, local: true, confirmation_pending: false, deactivated: true)
+ test "returns :password_reset_pending for user with reset password" do
+ user = insert(:user, password_reset_pending: true)
+ assert User.account_status(user) == :password_reset_pending
+ end
- refute User.auth_active?(deactivated_but_confirmed)
+ test "returns :deactivated for deactivated user" do
+ user = insert(:user, local: true, confirmation_pending: false, deactivated: true)
+ assert User.account_status(user) == :deactivated
+ end
end
describe "superuser?/1" do
@@ -1290,7 +1355,7 @@ defmodule Pleroma.UserTest do
bio = "A.k.a. @nick@domain.com"
expected_text =
- ~s(A.k.a. @nick@domain.com)
@@ -1324,7 +1389,8 @@ defmodule Pleroma.UserTest do
{:ok, _follower2} = User.follow(follower2, user)
{:ok, _follower3} = User.follow(follower3, user)
- {:ok, user} = User.block(user, follower)
+ {:ok, _user_relationship} = User.block(user, follower)
+ user = refresh_record(user)
assert user.follower_count == 2
end
@@ -1545,7 +1611,7 @@ defmodule Pleroma.UserTest do
end
describe "following/followers synchronization" do
- clear_config([:instance, :external_user_synchronization])
+ setup do: clear_config([:instance, :external_user_synchronization])
test "updates the counters normally on following/getting a follow when disabled" do
Pleroma.Config.put([:instance, :external_user_synchronization], false)
@@ -1644,17 +1710,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
+ setup do: 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