Improved in-test `clear_config/n` applicability (setup / setup_all / in-test usage).

This commit is contained in:
Ivan Tashkinov 2020-03-20 18:33:00 +03:00
parent 0e27c274f4
commit 1c05f539aa
84 changed files with 196 additions and 298 deletions

View File

@ -7,7 +7,7 @@ defmodule Pleroma.ActivityExpirationTest do
alias Pleroma.ActivityExpiration alias Pleroma.ActivityExpiration
import Pleroma.Factory import Pleroma.Factory
clear_config([ActivityExpiration, :enabled]) setup do: clear_config([ActivityExpiration, :enabled])
test "finds activities due to be deleted only" do test "finds activities due to be deleted only" do
activity = insert(:note_activity) activity = insert(:note_activity)

View File

@ -138,7 +138,7 @@ test "when association is not loaded" do
} }
end end
clear_config([:instance, :limit_to_local_content]) setup do: clear_config([:instance, :limit_to_local_content])
test "finds utf8 text in statuses", %{ test "finds utf8 text in statuses", %{
japanese_activity: japanese_activity, japanese_activity: japanese_activity,

View File

@ -12,8 +12,7 @@ defmodule Pleroma.CaptchaTest do
alias Pleroma.Captcha.Native alias Pleroma.Captcha.Native
@ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}] @ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}]
setup do: clear_config([Pleroma.Captcha, :enabled])
clear_config([Pleroma.Captcha, :enabled])
describe "Kocaptcha" do describe "Kocaptcha" do
setup do setup do

View File

@ -10,7 +10,7 @@ defmodule Pleroma.Config.TransferTaskTest do
alias Pleroma.Config.TransferTask alias Pleroma.Config.TransferTask
alias Pleroma.ConfigDB alias Pleroma.ConfigDB
clear_config(:configurable_from_database, true) setup do: clear_config(:configurable_from_database, true)
test "transfer config values from db to env" do test "transfer config values from db to env" do
refute Application.get_env(:pleroma, :test_key) refute Application.get_env(:pleroma, :test_key)

View File

@ -11,7 +11,7 @@ defmodule Pleroma.ConversationTest do
import Pleroma.Factory import Pleroma.Factory
clear_config_all([:instance, :federating], true) setup_all do: clear_config([:instance, :federating], true)
test "it goes through old direct conversations" do test "it goes through old direct conversations" do
user = insert(:user) user = insert(:user)

View File

@ -14,8 +14,7 @@ defmodule Pleroma.Emails.MailerTest do
subject: "Pleroma test email", subject: "Pleroma test email",
to: [{"Test User", "user1@example.com"}] to: [{"Test User", "user1@example.com"}]
} }
setup do: clear_config([Pleroma.Emails.Mailer, :enabled])
clear_config([Pleroma.Emails.Mailer, :enabled])
test "not send email when mailer is disabled" do test "not send email when mailer is disabled" do
Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false) Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)

View File

@ -8,8 +8,8 @@ defmodule Pleroma.HTTP.RequestBuilderTest do
alias Pleroma.HTTP.RequestBuilder alias Pleroma.HTTP.RequestBuilder
describe "headers/2" do describe "headers/2" do
clear_config([:http, :send_user_agent]) setup do: clear_config([:http, :send_user_agent])
clear_config([:http, :user_agent]) setup do: clear_config([:http, :user_agent])
test "don't send pleroma user agent" do test "don't send pleroma user agent" do
assert RequestBuilder.headers(%{}, []) == %{headers: []} assert RequestBuilder.headers(%{}, []) == %{headers: []}

View File

@ -28,8 +28,7 @@ defmodule Pleroma.Object.FetcherTest do
describe "max thread distance restriction" do describe "max thread distance restriction" do
@ap_id "http://mastodon.example.org/@admin/99541947525187367" @ap_id "http://mastodon.example.org/@admin/99541947525187367"
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
clear_config([:instance, :federation_incoming_replies_max_depth])
test "it returns thread depth exceeded error if thread depth is exceeded" do test "it returns thread depth exceeded error if thread depth is exceeded" do
Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0) Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
@ -160,7 +159,7 @@ test "it can refetch pruned objects" do
end end
describe "signed fetches" do describe "signed fetches" do
clear_config([:activitypub, :sign_object_fetches]) setup do: clear_config([:activitypub, :sign_object_fetches])
test_with_mock "it signs fetches when configured to do so", test_with_mock "it signs fetches when configured to do so",
Pleroma.Signature, Pleroma.Signature,

View File

@ -74,8 +74,8 @@ test "ensures cache is cleared for the object" do
end end
describe "delete attachments" do describe "delete attachments" do
clear_config([Pleroma.Upload]) setup do: clear_config([Pleroma.Upload])
clear_config([:instance, :cleanup_attachments]) setup do: clear_config([:instance, :cleanup_attachments])
test "Disabled via config" do test "Disabled via config" do
Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local) Pleroma.Config.put([Pleroma.Upload, :uploader], Pleroma.Uploaders.Local)

View File

@ -23,7 +23,7 @@ test "does nothing if a user is assigned", %{conn: conn} do
end end
describe "when secret set it assigns an admin user" do describe "when secret set it assigns an admin user" do
clear_config([:admin_token]) setup do: clear_config([:admin_token])
test "with `admin_token` query parameter", %{conn: conn} do test "with `admin_token` query parameter", %{conn: conn} do
Pleroma.Config.put(:admin_token, "password123") Pleroma.Config.put(:admin_token, "password123")

View File

@ -9,7 +9,7 @@ defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlugTest do
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
alias Pleroma.User alias Pleroma.User
clear_config([:instance, :public]) setup do: clear_config([:instance, :public])
test "it halts if not public and no user is assigned", %{conn: conn} do test "it halts if not public and no user is assigned", %{conn: conn} do
Config.put([:instance, :public], false) Config.put([:instance, :public], false)

View File

@ -7,9 +7,9 @@ defmodule Pleroma.Web.Plugs.HTTPSecurityPlugTest do
alias Pleroma.Config alias Pleroma.Config
alias Plug.Conn alias Plug.Conn
clear_config([:http_securiy, :enabled]) setup do: clear_config([:http_securiy, :enabled])
clear_config([:http_security, :sts]) setup do: clear_config([:http_security, :sts])
clear_config([:http_security, :referrer_policy]) setup do: clear_config([:http_security, :referrer_policy])
describe "http security enabled" do describe "http security enabled" do
setup do setup do

View File

@ -12,7 +12,7 @@ defmodule Pleroma.Web.RuntimeStaticPlugTest do
on_exit(fn -> File.rm_rf(@dir) end) on_exit(fn -> File.rm_rf(@dir) end)
end end
clear_config([:instance, :static_dir], @dir) setup do: clear_config([:instance, :static_dir], @dir)
test "overrides index" do test "overrides index" do
bundled_index = get(build_conn(), "/") bundled_index = get(build_conn(), "/")

View File

@ -193,7 +193,7 @@ test "filters scopes which directly match or are ancestors of supported scopes"
end end
describe "transform_scopes/2" do describe "transform_scopes/2" do
clear_config([:auth, :enforce_oauth_admin_scope_usage]) setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage])
setup do setup do
{:ok, %{f: &OAuthScopesPlug.transform_scopes/2}} {:ok, %{f: &OAuthScopesPlug.transform_scopes/2}}

View File

@ -12,14 +12,12 @@ defmodule Pleroma.Plugs.RateLimiterTest do
import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2] import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2]
# Note: each example must work with separate buckets in order to prevent concurrency issues # Note: each example must work with separate buckets in order to prevent concurrency issues
setup do: clear_config([Pleroma.Web.Endpoint, :http, :ip])
clear_config([Pleroma.Web.Endpoint, :http, :ip]) setup do: clear_config(:rate_limit)
clear_config(:rate_limit)
describe "config" do describe "config" do
@limiter_name :test_init @limiter_name :test_init
setup do: clear_config([Pleroma.Plugs.RemoteIp, :enabled])
clear_config([Pleroma.Plugs.RemoteIp, :enabled])
test "config is required for plug to work" do test "config is required for plug to work" do
Config.put([:rate_limit, @limiter_name], {1, 1}) Config.put([:rate_limit, @limiter_name], {1, 1})

View File

@ -9,8 +9,7 @@ defmodule Pleroma.Plugs.RemoteIpTest do
alias Pleroma.Plugs.RemoteIp alias Pleroma.Plugs.RemoteIp
import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2] import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2]
setup do: clear_config(RemoteIp)
clear_config(RemoteIp)
test "disabled" do test "disabled" do
Pleroma.Config.put(RemoteIp, enabled: false) Pleroma.Config.put(RemoteIp, enabled: false)

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Plugs.UserEnabledPlugTest do
alias Pleroma.Plugs.UserEnabledPlug alias Pleroma.Plugs.UserEnabledPlug
import Pleroma.Factory import Pleroma.Factory
clear_config([:instance, :account_activation_required]) setup do: clear_config([:instance, :account_activation_required])
test "doesn't do anything if the user isn't set", %{conn: conn} do test "doesn't do anything if the user isn't set", %{conn: conn} do
ret_conn = ret_conn =

View File

@ -9,7 +9,7 @@ defmodule Pleroma.Plugs.UserIsAdminPlugTest do
import Pleroma.Factory import Pleroma.Factory
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
clear_config([:auth, :enforce_oauth_admin_scope_usage], false) setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
test "accepts a user that is an admin" do test "accepts a user that is an admin" do
user = insert(:user, is_admin: true) user = insert(:user, is_admin: true)
@ -40,7 +40,7 @@ test "denies when a user isn't set" do
end end
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
clear_config([:auth, :enforce_oauth_admin_scope_usage], true) setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], true)
setup do setup do
admin_user = insert(:user, is_admin: true) admin_user = insert(:user, is_admin: true)

View File

@ -67,7 +67,7 @@ test "return error if has not assoc " do
:ok :ok
end end
clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check]) setup do: clear_config([:i_am_aware_this_may_cause_data_loss, :disable_migration_check])
test "raises if it detects unapplied migrations" do test "raises if it detects unapplied migrations" do
assert_raise Pleroma.Repo.UnappliedMigrationsError, fn -> assert_raise Pleroma.Repo.UnappliedMigrationsError, fn ->

View File

@ -8,7 +8,7 @@ defmodule Pleroma.ScheduledActivityTest do
alias Pleroma.ScheduledActivity alias Pleroma.ScheduledActivity
import Pleroma.Factory import Pleroma.Factory
clear_config([ScheduledActivity, :enabled]) setup do: clear_config([ScheduledActivity, :enabled])
setup context do setup context do
DataCase.ensure_local_uploader(context) DataCase.ensure_local_uploader(context)

View File

@ -17,14 +17,12 @@ defmacro clear_config(config_path) do
defmacro clear_config(config_path, do: yield) do defmacro clear_config(config_path, do: yield) do
quote do quote do
setup do
initial_setting = Config.get(unquote(config_path)) initial_setting = Config.get(unquote(config_path))
unquote(yield) unquote(yield)
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end) on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
:ok :ok
end end
end end
end
defmacro clear_config(config_path, temp_setting) do defmacro clear_config(config_path, temp_setting) do
quote do quote do
@ -34,58 +32,12 @@ defmacro clear_config(config_path, temp_setting) do
end end
end end
@doc """
From _within a test case_, sets config to provided value and restores initial value on exit.
For multi-case setup use `clear_config/2` instead.
"""
def set_config(config_path, temp_setting) do
initial_setting = Config.get(config_path)
Config.put(config_path, temp_setting)
ExUnit.Callbacks.on_exit(fn -> Config.put(config_path, initial_setting) end)
end
@doc "Stores initial config value and restores it after *all* test examples are executed."
defmacro clear_config_all(config_path) do
quote do
clear_config_all(unquote(config_path)) do
end
end
end
@doc """
Stores initial config value and restores it after *all* test examples are executed.
Only use if *all* test examples should work with the same stubbed value
(*no* examples set a different value).
"""
defmacro clear_config_all(config_path, do: yield) do
quote do
setup_all do
initial_setting = Config.get(unquote(config_path))
unquote(yield)
on_exit(fn -> Config.put(unquote(config_path), initial_setting) end)
:ok
end
end
end
defmacro clear_config_all(config_path, temp_setting) do
quote do
clear_config_all(unquote(config_path)) do
Config.put(unquote(config_path), unquote(temp_setting))
end
end
end
defmacro __using__(_opts) do defmacro __using__(_opts) do
quote do quote do
import Pleroma.Tests.Helpers, import Pleroma.Tests.Helpers,
only: [ only: [
clear_config: 1, clear_config: 1,
clear_config: 2, clear_config: 2
clear_config_all: 1,
clear_config_all: 2,
set_config: 2
] ]
def to_datetime(naive_datetime) do def to_datetime(naive_datetime) do

View File

@ -20,7 +20,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
:ok :ok
end end
clear_config_all(:configurable_from_database, true) setup_all do: clear_config(:configurable_from_database, true)
test "error if file with custom settings doesn't exist" do test "error if file with custom settings doesn't exist" do
Mix.Tasks.Pleroma.Config.migrate_to_db("config/not_existance_config_file.exs") Mix.Tasks.Pleroma.Config.migrate_to_db("config/not_existance_config_file.exs")

View File

@ -7,7 +7,7 @@ defmodule Mix.Tasks.Pleroma.RobotsTxtTest do
use Pleroma.Tests.Helpers use Pleroma.Tests.Helpers
alias Mix.Tasks.Pleroma.RobotsTxt alias Mix.Tasks.Pleroma.RobotsTxt
clear_config([:instance, :static_dir]) setup do: clear_config([:instance, :static_dir])
test "creates new dir" do test "creates new dir" do
path = "test/fixtures/new_dir/" path = "test/fixtures/new_dir/"

View File

@ -18,7 +18,7 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilenameTest do
%{upload_file: upload_file} %{upload_file: upload_file}
end end
clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text]) setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
test "it replaces filename on pre-defined text", %{upload_file: upload_file} do test "it replaces filename on pre-defined text", %{upload_file: upload_file} do
Config.put([Upload.Filter.AnonymizeFilename, :text], "custom-file.png") Config.put([Upload.Filter.AnonymizeFilename, :text], "custom-file.png")

View File

@ -10,7 +10,7 @@ defmodule Pleroma.Upload.Filter.MogrifyTest do
alias Pleroma.Upload alias Pleroma.Upload
alias Pleroma.Upload.Filter alias Pleroma.Upload.Filter
clear_config([Filter.Mogrify, :args]) setup do: clear_config([Filter.Mogrify, :args])
test "apply mogrify filter" do test "apply mogrify filter" do
Config.put([Filter.Mogrify, :args], [{"tint", "40"}]) Config.put([Filter.Mogrify, :args], [{"tint", "40"}])

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Upload.FilterTest do
alias Pleroma.Config alias Pleroma.Config
alias Pleroma.Upload.Filter alias Pleroma.Upload.Filter
clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text]) setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
test "applies filters" do test "applies filters" do
Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png") Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")

View File

@ -250,7 +250,7 @@ test "escapes reserved uri characters" do
end end
describe "Setting a custom base_url for uploaded media" do describe "Setting a custom base_url for uploaded media" do
clear_config([Pleroma.Upload, :base_url], "https://cache.pleroma.social") setup do: clear_config([Pleroma.Upload, :base_url], "https://cache.pleroma.social")
test "returns a media url with configured base_url" do test "returns a media url with configured base_url" do
base_url = Pleroma.Config.get([Pleroma.Upload, :base_url]) base_url = Pleroma.Config.get([Pleroma.Upload, :base_url])

View File

@ -11,6 +11,7 @@ defmodule Pleroma.Uploaders.S3Test do
import Mock import Mock
import ExUnit.CaptureLog import ExUnit.CaptureLog
setup do:
clear_config(Pleroma.Uploaders.S3, clear_config(Pleroma.Uploaders.S3,
bucket: "test_bucket", bucket: "test_bucket",
public_endpoint: "https://s3.amazonaws.com" public_endpoint: "https://s3.amazonaws.com"

View File

@ -15,7 +15,7 @@ defmodule Pleroma.UserSearchTest do
end end
describe "User.search" do describe "User.search" do
clear_config([:instance, :limit_to_local_content]) setup do: clear_config([:instance, :limit_to_local_content])
test "excluded invisible users from results" do test "excluded invisible users from results" do
user = insert(:user, %{nickname: "john t1000"}) user = insert(:user, %{nickname: "john t1000"})

View File

@ -24,7 +24,7 @@ defmodule Pleroma.UserTest do
:ok :ok
end end
clear_config([:instance, :account_activation_required]) setup do: clear_config([:instance, :account_activation_required])
describe "service actors" do describe "service actors" do
test "returns updated invisible actor" do test "returns updated invisible actor" do
@ -297,7 +297,7 @@ test "local users do not automatically follow local locked accounts" do
end end
describe "unfollow/2" do describe "unfollow/2" do
clear_config([:instance, :external_user_synchronization]) setup do: clear_config([:instance, :external_user_synchronization])
test "unfollow with syncronizes external user" do test "unfollow with syncronizes external user" do
Pleroma.Config.put([:instance, :external_user_synchronization], true) Pleroma.Config.put([:instance, :external_user_synchronization], true)
@ -375,10 +375,9 @@ test "fetches correct profile for nickname beginning with number" do
password_confirmation: "test", password_confirmation: "test",
email: "email@example.com" email: "email@example.com"
} }
setup do: clear_config([:instance, :autofollowed_nicknames])
clear_config([:instance, :autofollowed_nicknames]) setup do: clear_config([:instance, :welcome_message])
clear_config([:instance, :welcome_message]) setup do: clear_config([:instance, :welcome_user_nickname])
clear_config([:instance, :welcome_user_nickname])
test "it autofollows accounts that are set for it" do test "it autofollows accounts that are set for it" do
user = insert(:user) user = insert(:user)
@ -412,7 +411,7 @@ test "it sends a welcome message if it is set" do
assert activity.actor == welcome_user.ap_id assert activity.actor == welcome_user.ap_id
end end
clear_config([:instance, :account_activation_required]) 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 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) Pleroma.Config.put([:instance, :account_activation_required], true)
@ -475,8 +474,7 @@ test "it sets the password_hash and ap_id" do
password_confirmation: "test", password_confirmation: "test",
email: "email@example.com" email: "email@example.com"
} }
setup do: clear_config([:instance, :account_activation_required], true)
clear_config([:instance, :account_activation_required], true)
test "it creates unconfirmed user" do test "it creates unconfirmed user" do
changeset = User.register_changeset(%User{}, @full_user_data) changeset = User.register_changeset(%User{}, @full_user_data)
@ -619,9 +617,8 @@ test "returns an ap_followers link for a user" do
ap_id: "http...", ap_id: "http...",
avatar: %{some: "avatar"} avatar: %{some: "avatar"}
} }
setup do: clear_config([:instance, :user_bio_length])
clear_config([:instance, :user_bio_length]) setup do: clear_config([:instance, :user_name_length])
clear_config([:instance, :user_name_length])
test "it confirms validity" do test "it confirms validity" do
cs = User.remote_user_creation(@valid_remote) cs = User.remote_user_creation(@valid_remote)
@ -1114,7 +1111,7 @@ test "hide a user's statuses from timelines and notifications" do
[user: user] [user: user]
end end
clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
test ".delete_user_activities deletes all create activities", %{user: user} do test ".delete_user_activities deletes all create activities", %{user: user} do
{:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "2hu"})
@ -1295,7 +1292,7 @@ test "User.delete() plugs any possible zombie objects" do
end end
describe "account_status/1" do describe "account_status/1" do
clear_config([:instance, :account_activation_required]) setup do: clear_config([:instance, :account_activation_required])
test "return confirmation_pending for unconfirm user" do test "return confirmation_pending for unconfirm user" do
Pleroma.Config.put([:instance, :account_activation_required], true) Pleroma.Config.put([:instance, :account_activation_required], true)
@ -1663,7 +1660,7 @@ test "performs update cache if user updated" do
end end
describe "following/followers synchronization" do 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 test "updates the counters normally on following/getting a follow when disabled" do
Pleroma.Config.put([:instance, :external_user_synchronization], false) Pleroma.Config.put([:instance, :external_user_synchronization], false)
@ -1768,7 +1765,7 @@ test "changes email", %{user: user} do
[local_user: local_user, remote_user: remote_user] [local_user: local_user, remote_user: remote_user]
end end
clear_config([:instance, :limit_to_local_content]) 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", %{ test "allows getting remote users by id no matter what :limit_to_local_content is set to", %{
remote_user: remote_user remote_user: remote_user

View File

@ -26,10 +26,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
:ok :ok
end end
clear_config([:instance, :federating], true) setup do: clear_config([:instance, :federating], true)
describe "/relay" do describe "/relay" do
clear_config([:instance, :allow_relay]) setup do: clear_config([:instance, :allow_relay])
test "with the relay active, it returns the relay user", %{conn: conn} do test "with the relay active, it returns the relay user", %{conn: conn} do
res = res =
@ -1225,8 +1225,8 @@ test "GET /api/ap/whoami", %{conn: conn} do
|> json_response(403) |> json_response(403)
end end
clear_config([:media_proxy]) setup do: clear_config([:media_proxy])
clear_config([Pleroma.Upload]) setup do: clear_config([Pleroma.Upload])
test "POST /api/ap/upload_media", %{conn: conn} do test "POST /api/ap/upload_media", %{conn: conn} do
user = insert(:user) user = insert(:user)

View File

@ -27,7 +27,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
:ok :ok
end end
clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
describe "streaming out participations" do describe "streaming out participations" do
test "it streams them out" do test "it streams them out" do
@ -1396,7 +1396,7 @@ test "creates an undo activity for the last block" do
end end
describe "deletion" do describe "deletion" do
clear_config([:instance, :rewrite_policy]) setup do: clear_config([:instance, :rewrite_policy])
test "it reverts deletion on error" do test "it reverts deletion on error" do
note = insert(:note_activity) note = insert(:note_activity)
@ -1580,7 +1580,7 @@ test "it filters broken threads" do
end end
describe "update" do describe "update" do
clear_config([:instance, :max_pinned_statuses]) setup do: clear_config([:instance, :max_pinned_statuses])
test "it creates an update activity with the new user data" do test "it creates an update activity with the new user data" do
user = insert(:user) user = insert(:user)

View File

@ -26,7 +26,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
[user: user, message: message] [user: user, message: message]
end end
clear_config(:mrf_hellthread) setup do: clear_config(:mrf_hellthread)
describe "reject" do describe "reject" do
test "rejects the message if the recipient count is above reject_threshold", %{ test "rejects the message if the recipient count is above reject_threshold", %{

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
alias Pleroma.Web.ActivityPub.MRF.KeywordPolicy alias Pleroma.Web.ActivityPub.MRF.KeywordPolicy
clear_config(:mrf_keyword) setup do: clear_config(:mrf_keyword)
setup do setup do
Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []}) Pleroma.Config.put([:mrf_keyword], %{reject: [], federated_timeline_removal: [], replace: []})

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
alias Pleroma.Web.ActivityPub.MRF.MentionPolicy alias Pleroma.Web.ActivityPub.MRF.MentionPolicy
clear_config(:mrf_mention) setup do: clear_config(:mrf_mention)
test "pass filter if allow list is empty" do test "pass filter if allow list is empty" do
Pleroma.Config.delete([:mrf_mention]) Pleroma.Config.delete([:mrf_mention])

View File

@ -60,7 +60,7 @@ test "matches are case-insensitive" do
end end
describe "describe/0" do describe "describe/0" do
clear_config([:instance, :rewrite_policy]) setup do: clear_config([:instance, :rewrite_policy])
test "it works as expected with noop policy" do test "it works as expected with noop policy" do
expected = %{ expected = %{

View File

@ -9,6 +9,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy alias Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy
alias Pleroma.Web.ActivityPub.Visibility alias Pleroma.Web.ActivityPub.Visibility
setup do:
clear_config(:mrf_object_age, clear_config(:mrf_object_age,
threshold: 172_800, threshold: 172_800,
actions: [:delist, :strip_followers] actions: [:delist, :strip_followers]

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublicTest do
alias Pleroma.Web.ActivityPub.MRF.RejectNonPublic alias Pleroma.Web.ActivityPub.MRF.RejectNonPublic
clear_config([:mrf_rejectnonpublic]) setup do: clear_config([:mrf_rejectnonpublic])
describe "public message" do describe "public message" do
test "it's allowed when address is public" do test "it's allowed when address is public" do

View File

@ -8,6 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
alias Pleroma.Config alias Pleroma.Config
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
setup do:
clear_config(:mrf_simple, clear_config(:mrf_simple,
media_removal: [], media_removal: [],
media_nsfw: [], media_nsfw: [],

View File

@ -13,8 +13,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicyTest do
"type" => "Create", "type" => "Create",
"object" => %{"content" => "hi"} "object" => %{"content" => "hi"}
} }
setup do: clear_config([:mrf_subchain, :match_actor])
clear_config([:mrf_subchain, :match_actor])
test "it matches and processes subchains when the actor matches a configured target" do test "it matches and processes subchains when the actor matches a configured target" do
Pleroma.Config.put([:mrf_subchain, :match_actor], %{ Pleroma.Config.put([:mrf_subchain, :match_actor], %{

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicyTest do
alias Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy alias Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy
clear_config([:mrf_user_allowlist, :localhost]) setup do: clear_config([:mrf_user_allowlist, :localhost])
test "pass filter if allow list is empty" do test "pass filter if allow list is empty" do
actor = insert(:user) actor = insert(:user)

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
alias Pleroma.Web.ActivityPub.MRF.VocabularyPolicy alias Pleroma.Web.ActivityPub.MRF.VocabularyPolicy
describe "accept" do describe "accept" do
clear_config([:mrf_vocabulary, :accept]) setup do: clear_config([:mrf_vocabulary, :accept])
test "it accepts based on parent activity type" do test "it accepts based on parent activity type" do
Pleroma.Config.put([:mrf_vocabulary, :accept], ["Like"]) Pleroma.Config.put([:mrf_vocabulary, :accept], ["Like"])
@ -65,7 +65,7 @@ test "it does not accept disallowed parent types" do
end end
describe "reject" do describe "reject" do
clear_config([:mrf_vocabulary, :reject]) setup do: clear_config([:mrf_vocabulary, :reject])
test "it rejects based on parent activity type" do test "it rejects based on parent activity type" do
Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"]) Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"])

View File

@ -23,7 +23,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
:ok :ok
end end
clear_config_all([:instance, :federating], true) setup_all do: clear_config([:instance, :federating], true)
describe "gather_webfinger_links/1" do describe "gather_webfinger_links/1" do
test "it returns links" do test "it returns links" do

View File

@ -68,7 +68,7 @@ test "returns activity" do
end end
describe "publish/1" do describe "publish/1" do
clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
test "returns error when activity not `Create` type" do test "returns error when activity not `Create` type" do
activity = insert(:like_activity) activity = insert(:like_activity)

View File

@ -19,7 +19,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
end end
describe "handle_incoming" do describe "handle_incoming" do
clear_config([:user, :deny_follow_blocked]) setup do: clear_config([:user, :deny_follow_blocked])
test "it works for osada follow request" do test "it works for osada follow request" do
user = insert(:user) user = insert(:user)

View File

@ -25,7 +25,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
:ok :ok
end end
clear_config([:instance, :max_remote_account_fields]) setup do: clear_config([:instance, :max_remote_account_fields])
describe "handle_incoming" do describe "handle_incoming" do
test "it ignores an incoming notice if we already have it" do test "it ignores an incoming notice if we already have it" do
@ -1351,9 +1351,8 @@ test "it accepts Move activities" do
end end
describe "`handle_incoming/2`, Mastodon format `replies` handling" do describe "`handle_incoming/2`, Mastodon format `replies` handling" do
clear_config([:activitypub, :note_replies_output_limit], 5) setup do: clear_config([:activitypub, :note_replies_output_limit], 5)
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
clear_config([:instance, :federation_incoming_replies_max_depth])
setup do setup do
data = data =
@ -1392,9 +1391,8 @@ test "does NOT schedule background fetching of `replies` beyond max thread depth
end end
describe "`handle_incoming/2`, Pleroma format `replies` handling" do describe "`handle_incoming/2`, Pleroma format `replies` handling" do
clear_config([:activitypub, :note_replies_output_limit], 5) setup do: clear_config([:activitypub, :note_replies_output_limit], 5)
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
clear_config([:instance, :federation_incoming_replies_max_depth])
setup do setup do
user = insert(:user) user = insert(:user)
@ -1878,7 +1876,7 @@ test "returns fixed object" do
end end
describe "fix_in_reply_to/2" do describe "fix_in_reply_to/2" do
clear_config([:instance, :federation_incoming_replies_max_depth]) setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
setup do setup do
data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json")) data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json"))
@ -2141,7 +2139,7 @@ test "returns object with emoji when object contains map tag" do
end end
describe "set_replies/1" do describe "set_replies/1" do
clear_config([:activitypub, :note_replies_output_limit], 2) setup do: clear_config([:activitypub, :note_replies_output_limit], 2)
test "returns unmodified object if activity doesn't have self-replies" do test "returns unmodified object if activity doesn't have self-replies" do
data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json")) data = Poison.decode!(File.read!("test/fixtures/mastodon-post-activity.json"))

View File

@ -37,7 +37,7 @@ test "renders a note activity" do
end end
describe "note activity's `replies` collection rendering" do describe "note activity's `replies` collection rendering" do
clear_config([:activitypub, :note_replies_output_limit], 5) setup do: clear_config([:activitypub, :note_replies_output_limit], 5)
test "renders `replies` collection for a note activity" do test "renders `replies` collection for a note activity" do
user = insert(:user) user = insert(:user)

View File

@ -43,7 +43,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
end end
describe "with [:auth, :enforce_oauth_admin_scope_usage]," do describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
clear_config([:auth, :enforce_oauth_admin_scope_usage], true) setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], true)
test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope", test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or broader scope",
%{admin: admin} do %{admin: admin} do
@ -91,7 +91,7 @@ test "GET /api/pleroma/admin/users/:nickname requires admin:read:accounts or bro
end end
describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
clear_config([:auth, :enforce_oauth_admin_scope_usage], false) setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
test "GET /api/pleroma/admin/users/:nickname requires " <> test "GET /api/pleroma/admin/users/:nickname requires " <>
"read:accounts or admin:read:accounts or broader scope", "read:accounts or admin:read:accounts or broader scope",
@ -577,8 +577,8 @@ test "/:right DELETE, can remove from a permission group (multiple)", %{
end end
describe "POST /api/pleroma/admin/email_invite, with valid config" do describe "POST /api/pleroma/admin/email_invite, with valid config" do
clear_config([:instance, :registrations_open], false) setup do: clear_config([:instance, :registrations_open], false)
clear_config([:instance, :invites_enabled], true) setup do: clear_config([:instance, :invites_enabled], true)
test "sends invitation and returns 204", %{admin: admin, conn: conn} do test "sends invitation and returns 204", %{admin: admin, conn: conn} do
recipient_email = "foo@bar.com" recipient_email = "foo@bar.com"
@ -629,8 +629,8 @@ test "it returns 403 if requested by a non-admin" do
end end
describe "POST /api/pleroma/admin/users/email_invite, with invalid config" do describe "POST /api/pleroma/admin/users/email_invite, with invalid config" do
clear_config([:instance, :registrations_open]) setup do: clear_config([:instance, :registrations_open])
clear_config([:instance, :invites_enabled]) setup do: clear_config([:instance, :invites_enabled])
test "it returns 500 if `invites_enabled` is not enabled", %{conn: conn} do test "it returns 500 if `invites_enabled` is not enabled", %{conn: conn} do
Config.put([:instance, :registrations_open], false) Config.put([:instance, :registrations_open], false)
@ -1879,7 +1879,7 @@ test "returns 404 when the status does not exist", %{conn: conn} do
end end
describe "GET /api/pleroma/admin/config" do describe "GET /api/pleroma/admin/config" do
clear_config(:configurable_from_database, true) setup do: clear_config(:configurable_from_database, true)
test "when configuration from database is off", %{conn: conn} do test "when configuration from database is off", %{conn: conn} do
Config.put(:configurable_from_database, false) Config.put(:configurable_from_database, false)
@ -2030,7 +2030,7 @@ test "POST /api/pleroma/admin/config error", %{conn: conn} do
end) end)
end end
clear_config(:configurable_from_database, true) setup do: clear_config(:configurable_from_database, true)
@tag capture_log: true @tag capture_log: true
test "create new config setting in db", %{conn: conn} do test "create new config setting in db", %{conn: conn} do
@ -3039,7 +3039,7 @@ test "proxy tuple ip", %{conn: conn} do
end end
describe "GET /api/pleroma/admin/restart" do describe "GET /api/pleroma/admin/restart" do
clear_config(:configurable_from_database, true) setup do: clear_config(:configurable_from_database, true)
test "pleroma restarts", %{conn: conn} do test "pleroma restarts", %{conn: conn} do
capture_log(fn -> capture_log(fn ->

View File

@ -21,7 +21,7 @@ test "it broadcasts a message", %{socket: socket} do
end end
describe "message lengths" do describe "message lengths" do
clear_config([:instance, :chat_limit]) setup do: clear_config([:instance, :chat_limit])
test "it ignores messages of length zero", %{socket: socket} do test "it ignores messages of length zero", %{socket: socket} do
push(socket, "new_msg", %{"text" => ""}) push(socket, "new_msg", %{"text" => ""})

View File

@ -17,9 +17,9 @@ defmodule Pleroma.Web.CommonAPITest do
require Pleroma.Constants require Pleroma.Constants
clear_config([:instance, :safe_dm_mentions]) setup do: clear_config([:instance, :safe_dm_mentions])
clear_config([:instance, :limit]) setup do: clear_config([:instance, :limit])
clear_config([:instance, :max_pinned_statuses]) setup do: clear_config([:instance, :max_pinned_statuses])
test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do test "when replying to a conversation / participation, it will set the correct context id even if no explicit reply_to is given" do
user = insert(:user) user = insert(:user)

View File

@ -21,11 +21,10 @@ defmodule Pleroma.Web.FederatorTest do
:ok :ok
end end
clear_config_all([:instance, :federating], true) setup_all do: clear_config([:instance, :federating], true)
setup do: clear_config([:instance, :allow_relay])
clear_config([:instance, :allow_relay]) setup do: clear_config([:instance, :rewrite_policy])
clear_config([:instance, :rewrite_policy]) setup do: clear_config([:mrf_keyword])
clear_config([:mrf_keyword])
describe "Publish an activity" do describe "Publish an activity" do
setup do setup do

View File

@ -10,7 +10,7 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
alias Pleroma.Web.Feed.FeedView alias Pleroma.Web.Feed.FeedView
clear_config([:feed]) setup do: clear_config([:feed])
test "gets a feed (ATOM)", %{conn: conn} do test "gets a feed (ATOM)", %{conn: conn} do
Pleroma.Config.put( Pleroma.Config.put(

View File

@ -12,10 +12,10 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
alias Pleroma.Object alias Pleroma.Object
alias Pleroma.User alias Pleroma.User
clear_config([:instance, :federating], true) setup do: clear_config([:instance, :federating], true)
describe "feed" do describe "feed" do
clear_config([:feed]) setup do: clear_config([:feed])
test "gets a feed", %{conn: conn} do test "gets a feed", %{conn: conn} do
Config.put( Config.put(

View File

@ -10,7 +10,7 @@ defmodule Pleroma.Instances.InstanceTest do
import Pleroma.Factory import Pleroma.Factory
clear_config_all([:instance, :federation_reachability_timeout_days], 1) setup_all do: clear_config([:instance, :federation_reachability_timeout_days], 1)
describe "set_reachable/1" do describe "set_reachable/1" do
test "clears `unreachable_since` of existing matching Instance record having non-nil `unreachable_since`" do test "clears `unreachable_since` of existing matching Instance record having non-nil `unreachable_since`" do

View File

@ -7,7 +7,7 @@ defmodule Pleroma.InstancesTest do
use Pleroma.DataCase use Pleroma.DataCase
clear_config_all([:instance, :federation_reachability_timeout_days], 1) setup_all do: clear_config([:instance, :federation_reachability_timeout_days], 1)
describe "reachable?/1" do describe "reachable?/1" do
test "returns `true` for host / url with unknown reachability status" do test "returns `true` for host / url with unknown reachability status" do

View File

@ -10,7 +10,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do
import Pleroma.Factory import Pleroma.Factory
clear_config([:instance, :public]) setup do: clear_config([:instance, :public])
test "put settings", %{conn: conn} do test "put settings", %{conn: conn} do
user = insert(:user) user = insert(:user)

View File

@ -9,7 +9,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
use Pleroma.Web.ConnCase use Pleroma.Web.ConnCase
import Pleroma.Factory import Pleroma.Factory
clear_config([:instance, :max_account_fields])
setup do: clear_config([:instance, :max_account_fields])
describe "updating credentials" do describe "updating credentials" do
setup do: oauth_access(["write:accounts"]) setup do: oauth_access(["write:accounts"])

View File

@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
import Pleroma.Factory import Pleroma.Factory
describe "account fetching" do describe "account fetching" do
clear_config([:instance, :limit_to_local_content]) setup do: clear_config([:instance, :limit_to_local_content])
test "works by id" do test "works by id" do
user = insert(:user) user = insert(:user)
@ -150,13 +150,9 @@ defp local_and_remote_users do
describe "user fetching with restrict unauthenticated profiles for local and remote" do describe "user fetching with restrict unauthenticated profiles for local and remote" do
setup do: local_and_remote_users() setup do: local_and_remote_users()
clear_config([:restrict_unauthenticated, :profiles, :local]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
Config.put([:restrict_unauthenticated, :profiles, :local], true)
end
clear_config([:restrict_unauthenticated, :profiles, :remote]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/accounts/#{local.id}") res_conn = get(conn, "/api/v1/accounts/#{local.id}")
@ -186,9 +182,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "user fetching with restrict unauthenticated profiles for local" do describe "user fetching with restrict unauthenticated profiles for local" do
setup do: local_and_remote_users() setup do: local_and_remote_users()
clear_config([:restrict_unauthenticated, :profiles, :local]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
Config.put([:restrict_unauthenticated, :profiles, :local], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/accounts/#{local.id}") res_conn = get(conn, "/api/v1/accounts/#{local.id}")
@ -215,9 +209,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "user fetching with restrict unauthenticated profiles for remote" do describe "user fetching with restrict unauthenticated profiles for remote" do
setup do: local_and_remote_users() setup do: local_and_remote_users()
clear_config([:restrict_unauthenticated, :profiles, :remote]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/accounts/#{local.id}") res_conn = get(conn, "/api/v1/accounts/#{local.id}")
@ -405,13 +397,9 @@ defp local_and_remote_activities(%{local: local, remote: remote}) do
setup do: local_and_remote_users() setup do: local_and_remote_users()
setup :local_and_remote_activities setup :local_and_remote_activities
clear_config([:restrict_unauthenticated, :profiles, :local]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
Config.put([:restrict_unauthenticated, :profiles, :local], true)
end
clear_config([:restrict_unauthenticated, :profiles, :remote]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses") res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
@ -442,9 +430,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
setup do: local_and_remote_users() setup do: local_and_remote_users()
setup :local_and_remote_activities setup :local_and_remote_activities
clear_config([:restrict_unauthenticated, :profiles, :local]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :local], true)
Config.put([:restrict_unauthenticated, :profiles, :local], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses") res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
@ -472,9 +458,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
setup do: local_and_remote_users() setup do: local_and_remote_users()
setup :local_and_remote_activities setup :local_and_remote_activities
clear_config([:restrict_unauthenticated, :profiles, :remote]) do setup do: clear_config([:restrict_unauthenticated, :profiles, :remote], true)
Config.put([:restrict_unauthenticated, :profiles, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses") res_conn = get(conn, "/api/v1/accounts/#{local.id}/statuses")
@ -806,7 +790,7 @@ test "blocking / unblocking a user" do
[valid_params: valid_params] [valid_params: valid_params]
end end
clear_config([:instance, :account_activation_required]) setup do: clear_config([:instance, :account_activation_required])
test "Account registration via Application", %{conn: conn} do test "Account registration via Application", %{conn: conn} do
conn = conn =
@ -904,7 +888,7 @@ test "returns bad_request if missing required params", %{
end) end)
end end
clear_config([:instance, :account_activation_required]) setup do: clear_config([:instance, :account_activation_required])
test "returns bad_request if missing email params when :account_activation_required is enabled", test "returns bad_request if missing email params when :account_activation_required is enabled",
%{conn: conn, valid_params: valid_params} do %{conn: conn, valid_params: valid_params} do
@ -961,7 +945,7 @@ test "returns forbidden if token is invalid", %{conn: conn, valid_params: valid_
end end
describe "create account by app / rate limit" do describe "create account by app / rate limit" do
clear_config([:rate_limit, :app_account_creation], {10_000, 2}) setup do: clear_config([:rate_limit, :app_account_creation], {10_000, 2})
test "respects rate limit setting", %{conn: conn} do test "respects rate limit setting", %{conn: conn} do
app_token = insert(:oauth_token, user: nil) app_token = insert(:oauth_token, user: nil)

View File

@ -22,8 +22,8 @@ defmodule Pleroma.Web.MastodonAPI.MediaControllerTest do
[image: image] [image: image]
end end
clear_config([:media_proxy]) setup do: clear_config([:media_proxy])
clear_config([Pleroma.Upload]) setup do: clear_config([Pleroma.Upload])
test "returns uploaded image", %{conn: conn, image: image} do test "returns uploaded image", %{conn: conn, image: image} do
desc = "Description of the image" desc = "Description of the image"

View File

@ -11,7 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityControllerTest do
import Pleroma.Factory import Pleroma.Factory
import Ecto.Query import Ecto.Query
clear_config([ScheduledActivity, :enabled]) setup do: clear_config([ScheduledActivity, :enabled])
test "shows scheduled activities" do test "shows scheduled activities" do
%{user: user, conn: conn} = oauth_access(["read:statuses"]) %{user: user, conn: conn} = oauth_access(["read:statuses"])

View File

@ -19,9 +19,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
import Pleroma.Factory import Pleroma.Factory
clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
clear_config([:instance, :allow_relay]) setup do: clear_config([:instance, :allow_relay])
clear_config([:rich_media, :enabled]) setup do: clear_config([:rich_media, :enabled])
describe "posting statuses" do describe "posting statuses" do
setup do: oauth_access(["write:statuses"]) setup do: oauth_access(["write:statuses"])
@ -485,13 +485,9 @@ defp local_and_remote_activities do
describe "status with restrict unauthenticated activities for local and remote" do describe "status with restrict unauthenticated activities for local and remote" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :activities, :local]) do setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
Config.put([:restrict_unauthenticated, :activities, :local], true)
end
clear_config([:restrict_unauthenticated, :activities, :remote]) do setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
Config.put([:restrict_unauthenticated, :activities, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses/#{local.id}") res_conn = get(conn, "/api/v1/statuses/#{local.id}")
@ -520,9 +516,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "status with restrict unauthenticated activities for local" do describe "status with restrict unauthenticated activities for local" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :activities, :local]) do setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
Config.put([:restrict_unauthenticated, :activities, :local], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses/#{local.id}") res_conn = get(conn, "/api/v1/statuses/#{local.id}")
@ -548,9 +542,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "status with restrict unauthenticated activities for remote" do describe "status with restrict unauthenticated activities for remote" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :activities, :remote]) do setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
Config.put([:restrict_unauthenticated, :activities, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses/#{local.id}") res_conn = get(conn, "/api/v1/statuses/#{local.id}")
@ -614,13 +606,9 @@ test "get statuses by IDs" do
describe "getting statuses by ids with restricted unauthenticated for local and remote" do describe "getting statuses by ids with restricted unauthenticated for local and remote" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :activities, :local]) do setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
Config.put([:restrict_unauthenticated, :activities, :local], true)
end
clear_config([:restrict_unauthenticated, :activities, :remote]) do setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
Config.put([:restrict_unauthenticated, :activities, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]}) res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
@ -640,9 +628,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "getting statuses by ids with restricted unauthenticated for local" do describe "getting statuses by ids with restricted unauthenticated for local" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :activities, :local]) do setup do: clear_config([:restrict_unauthenticated, :activities, :local], true)
Config.put([:restrict_unauthenticated, :activities, :local], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]}) res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
@ -663,9 +649,7 @@ test "if user is authenticated", %{local: local, remote: remote} do
describe "getting statuses by ids with restricted unauthenticated for remote" do describe "getting statuses by ids with restricted unauthenticated for remote" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :activities, :remote]) do setup do: clear_config([:restrict_unauthenticated, :activities, :remote], true)
Config.put([:restrict_unauthenticated, :activities, :remote], true)
end
test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do test "if user is unauthenticated", %{conn: conn, local: local, remote: remote} do
res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]}) res_conn = get(conn, "/api/v1/statuses", %{ids: [local.id, remote.id]})
@ -908,7 +892,7 @@ test "returns 404 error for a wrong id", %{conn: conn} do
%{activity: activity} %{activity: activity}
end end
clear_config([:instance, :max_pinned_statuses], 1) setup do: clear_config([:instance, :max_pinned_statuses], 1)
test "pin status", %{conn: conn, user: user, activity: activity} do test "pin status", %{conn: conn, user: user, activity: activity} do
id_str = to_string(activity.id) id_str = to_string(activity.id)

View File

@ -100,13 +100,9 @@ defp local_and_remote_activities do
describe "public with restrict unauthenticated timeline for local and federated timelines" do describe "public with restrict unauthenticated timeline for local and federated timelines" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :timelines, :local]) do setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
Config.put([:restrict_unauthenticated, :timelines, :local], true)
end
clear_config([:restrict_unauthenticated, :timelines, :federated]) do setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
Config.put([:restrict_unauthenticated, :timelines, :federated], true)
end
test "if user is unauthenticated", %{conn: conn} do test "if user is unauthenticated", %{conn: conn} do
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"}) res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
@ -136,9 +132,7 @@ test "if user is authenticated" do
describe "public with restrict unauthenticated timeline for local" do describe "public with restrict unauthenticated timeline for local" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :timelines, :local]) do setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true)
Config.put([:restrict_unauthenticated, :timelines, :local], true)
end
test "if user is unauthenticated", %{conn: conn} do test "if user is unauthenticated", %{conn: conn} do
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"}) res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})
@ -165,9 +159,7 @@ test "if user is authenticated", %{conn: _conn} do
describe "public with restrict unauthenticated timeline for remote" do describe "public with restrict unauthenticated timeline for remote" do
setup do: local_and_remote_activities() setup do: local_and_remote_activities()
clear_config([:restrict_unauthenticated, :timelines, :federated]) do setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true)
Config.put([:restrict_unauthenticated, :timelines, :federated], true)
end
test "if user is unauthenticated", %{conn: conn} do test "if user is unauthenticated", %{conn: conn} do
res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"}) res_conn = get(conn, "/api/v1/timelines/public", %{"local" => "true"})

View File

@ -7,8 +7,8 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyControllerTest do
import Mock import Mock
alias Pleroma.Config alias Pleroma.Config
clear_config(:media_proxy) setup do: clear_config(:media_proxy)
clear_config([Pleroma.Web.Endpoint, :secret_key_base]) setup do: clear_config([Pleroma.Web.Endpoint, :secret_key_base])
test "it returns 404 when MediaProxy disabled", %{conn: conn} do test "it returns 404 when MediaProxy disabled", %{conn: conn} do
Config.put([:media_proxy, :enabled], false) Config.put([:media_proxy, :enabled], false)

View File

@ -8,8 +8,8 @@ defmodule Pleroma.Web.MediaProxyTest do
import Pleroma.Web.MediaProxy import Pleroma.Web.MediaProxy
alias Pleroma.Web.MediaProxy.MediaProxyController alias Pleroma.Web.MediaProxy.MediaProxyController
clear_config([:media_proxy, :enabled]) setup do: clear_config([:media_proxy, :enabled])
clear_config(Pleroma.Upload) setup do: clear_config(Pleroma.Upload)
describe "when enabled" do describe "when enabled" do
setup do setup do

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraphTest do
import Pleroma.Factory import Pleroma.Factory
alias Pleroma.Web.Metadata.Providers.OpenGraph alias Pleroma.Web.Metadata.Providers.OpenGraph
clear_config([Pleroma.Web.Metadata, :unfurl_nsfw]) setup do: clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
test "it renders all supported types of attachments and skips unknown types" do test "it renders all supported types of attachments and skips unknown types" do
user = insert(:user) user = insert(:user)

View File

@ -13,7 +13,7 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCardTest do
alias Pleroma.Web.Metadata.Utils alias Pleroma.Web.Metadata.Utils
alias Pleroma.Web.Router alias Pleroma.Web.Router
clear_config([Pleroma.Web.Metadata, :unfurl_nsfw]) setup do: clear_config([Pleroma.Web.Metadata, :unfurl_nsfw])
test "it renders twitter card for user info" do test "it renders twitter card for user info" do
user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994") user = insert(:user, name: "Jimmy Hendriks", bio: "born 19 March 1994")

View File

@ -7,8 +7,8 @@ defmodule Pleroma.Web.NodeInfoTest do
import Pleroma.Factory import Pleroma.Factory
clear_config([:mrf_simple]) setup do: clear_config([:mrf_simple])
clear_config(:instance) setup do: clear_config(:instance)
test "GET /.well-known/nodeinfo", %{conn: conn} do test "GET /.well-known/nodeinfo", %{conn: conn} do
links = links =
@ -105,7 +105,7 @@ test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do
end end
describe "`metadata/federation/enabled`" do describe "`metadata/federation/enabled`" do
clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
test "it shows if federation is enabled/disabled", %{conn: conn} do test "it shows if federation is enabled/disabled", %{conn: conn} do
Pleroma.Config.put([:instance, :federating], true) Pleroma.Config.put([:instance, :federating], true)

View File

@ -12,9 +12,9 @@ defmodule Pleroma.Web.OAuth.LDAPAuthorizationTest do
@skip if !Code.ensure_loaded?(:eldap), do: :skip @skip if !Code.ensure_loaded?(:eldap), do: :skip
clear_config_all([:ldap, :enabled], true) setup_all do: clear_config([:ldap, :enabled], true)
clear_config_all(Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.LDAPAuthenticator) setup_all do: clear_config(Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.LDAPAuthenticator)
@tag @skip @tag @skip
test "authorizes the existing user using LDAP credentials" do test "authorizes the existing user using LDAP credentials" do

View File

@ -17,8 +17,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
key: "_test", key: "_test",
signing_salt: "cooldude" signing_salt: "cooldude"
] ]
setup do: clear_config([:instance, :account_activation_required])
clear_config([:instance, :account_activation_required])
describe "in OAuth consumer mode, " do describe "in OAuth consumer mode, " do
setup do setup do
@ -31,7 +30,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
] ]
end end
clear_config([:auth, :oauth_consumer_strategies], ~w(twitter facebook)) setup do: clear_config([:auth, :oauth_consumer_strategies], ~w(twitter facebook))
test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{ test "GET /oauth/authorize renders auth forms, including OAuth consumer form", %{
app: app, app: app,
@ -939,7 +938,7 @@ test "rejects an invalid authorization code" do
end end
describe "POST /oauth/token - refresh token" do describe "POST /oauth/token - refresh token" do
clear_config([:oauth2, :issue_new_refresh_token]) setup do: clear_config([:oauth2, :issue_new_refresh_token])
test "issues a new access token with keep fresh token" do test "issues a new access token with keep fresh token" do
Pleroma.Config.put([:oauth2, :issue_new_refresh_token], true) Pleroma.Config.put([:oauth2, :issue_new_refresh_token], true)

View File

@ -17,7 +17,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
:ok :ok
end end
clear_config([:instance, :federating], true) setup do: clear_config([:instance, :federating], true)
# Note: see ActivityPubControllerTest for JSON format tests # Note: see ActivityPubControllerTest for JSON format tests
describe "GET /objects/:uuid (text/html)" do describe "GET /objects/:uuid (text/html)" do

View File

@ -27,7 +27,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
[user: user] [user: user]
end end
clear_config([:instance, :account_activation_required], true) setup do: clear_config([:instance, :account_activation_required], true)
test "resend account confirmation email", %{conn: conn, user: user} do test "resend account confirmation email", %{conn: conn, user: user} do
conn conn

View File

@ -12,8 +12,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiAPIControllerTest do
Pleroma.Config.get!([:instance, :static_dir]), Pleroma.Config.get!([:instance, :static_dir]),
"emoji" "emoji"
) )
setup do: clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
clear_config([:auth, :enforce_oauth_admin_scope_usage], false)
test "shared & non-shared pack information in list_packs is ok" do test "shared & non-shared pack information in list_packs is ok" do
conn = build_conn() conn = build_conn()

View File

@ -5,7 +5,7 @@
defmodule Pleroma.Web.FederatingPlugTest do defmodule Pleroma.Web.FederatingPlugTest do
use Pleroma.Web.ConnCase use Pleroma.Web.ConnCase
clear_config([:instance, :federating]) setup do: clear_config([:instance, :federating])
test "returns and halt the conn when federating is disabled" do test "returns and halt the conn when federating is disabled" do
Pleroma.Config.put([:instance, :federating], false) Pleroma.Config.put([:instance, :federating], false)

View File

@ -19,7 +19,7 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
:ok :ok
end end
clear_config([:rich_media, :enabled]) setup do: clear_config([:rich_media, :enabled])
test "refuses to crawl incomplete URLs" do test "refuses to crawl incomplete URLs" do
user = insert(:user) user = insert(:user)

View File

@ -8,9 +8,8 @@ defmodule Pleroma.Web.StaticFE.StaticFEControllerTest do
import Pleroma.Factory import Pleroma.Factory
clear_config_all([:static_fe, :enabled], true) setup_all do: clear_config([:static_fe, :enabled], true)
setup do: clear_config([:instance, :federating], true)
clear_config([:instance, :federating], true)
setup %{conn: conn} do setup %{conn: conn} do
conn = put_req_header(conn, "accept", "text/html") conn = put_req_header(conn, "accept", "text/html")

View File

@ -19,8 +19,7 @@ defmodule Pleroma.Web.StreamerTest do
@streamer_timeout 150 @streamer_timeout 150
@streamer_start_wait 10 @streamer_start_wait 10
setup do: clear_config([:instance, :skip_thread_containment])
clear_config([:instance, :skip_thread_containment])
describe "user streams" do describe "user streams" do
setup do setup do

View File

@ -17,11 +17,10 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
:ok :ok
end end
clear_config_all([:instance, :federating], true) setup_all do: clear_config([:instance, :federating], true)
setup do: clear_config([:instance])
clear_config([:instance]) setup do: clear_config([:frontend_configurations, :pleroma_fe])
clear_config([:frontend_configurations, :pleroma_fe]) setup do: clear_config([:user, :deny_follow_blocked])
clear_config([:user, :deny_follow_blocked])
describe "GET /ostatus_subscribe - remote_follow/2" do describe "GET /ostatus_subscribe - remote_follow/2" do
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do

View File

@ -117,7 +117,7 @@ test "it registers a new user and parses mentions in the bio" do
end end
describe "register with one time token" do describe "register with one time token" do
clear_config([:instance, :registrations_open], false) setup do: clear_config([:instance, :registrations_open], false)
test "returns user on success" do test "returns user on success" do
{:ok, invite} = UserInviteToken.create_invite() {:ok, invite} = UserInviteToken.create_invite()
@ -182,7 +182,7 @@ test "returns error on expired token" do
end end
describe "registers with date limited token" do describe "registers with date limited token" do
clear_config([:instance, :registrations_open], false) setup do: clear_config([:instance, :registrations_open], false)
setup do setup do
data = %{ data = %{
@ -242,7 +242,7 @@ test "returns an error on overdue date", %{data: data} do
end end
describe "registers with reusable token" do describe "registers with reusable token" do
clear_config([:instance, :registrations_open], false) setup do: clear_config([:instance, :registrations_open], false)
test "returns user on success, after him registration fails" do test "returns user on success, after him registration fails" do
{:ok, invite} = UserInviteToken.create_invite(%{max_use: 100}) {:ok, invite} = UserInviteToken.create_invite(%{max_use: 100})
@ -286,7 +286,7 @@ test "returns user on success, after him registration fails" do
end end
describe "registers with reusable date limited token" do describe "registers with reusable date limited token" do
clear_config([:instance, :registrations_open], false) setup do: clear_config([:instance, :registrations_open], false)
test "returns user on success" do test "returns user on success" do
{:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100}) {:ok, invite} = UserInviteToken.create_invite(%{expires_at: Date.utc_today(), max_use: 100})

View File

@ -18,8 +18,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
:ok :ok
end end
clear_config([:instance]) setup do: clear_config([:instance])
clear_config([:frontend_configurations, :pleroma_fe]) setup do: clear_config([:frontend_configurations, :pleroma_fe])
describe "POST /api/pleroma/follow_import" do describe "POST /api/pleroma/follow_import" do
setup do: oauth_access(["follow"]) setup do: oauth_access(["follow"])
@ -318,7 +318,7 @@ test "returns json with custom emoji with tags", %{conn: conn} do
end end
describe "GET /api/pleroma/healthcheck" do describe "GET /api/pleroma/healthcheck" do
clear_config([:instance, :healthcheck]) setup do: clear_config([:instance, :healthcheck])
test "returns 503 when healthcheck disabled", %{conn: conn} do test "returns 503 when healthcheck disabled", %{conn: conn} do
Config.put([:instance, :healthcheck], false) Config.put([:instance, :healthcheck], false)
@ -427,7 +427,7 @@ test "it returns version in json format", %{conn: conn} do
end end
describe "POST /main/ostatus - remote_subscribe/2" do describe "POST /main/ostatus - remote_subscribe/2" do
clear_config([:instance, :federating], true) setup do: clear_config([:instance, :federating], true)
test "renders subscribe form", %{conn: conn} do test "renders subscribe form", %{conn: conn} do
user = insert(:user) user = insert(:user)

View File

@ -14,7 +14,7 @@ defmodule Pleroma.Web.WebFinger.WebFingerControllerTest do
:ok :ok
end end
clear_config_all([:instance, :federating], true) setup_all do: clear_config([:instance, :federating], true)
test "GET host-meta" do test "GET host-meta" do
response = response =

View File

@ -8,7 +8,7 @@ defmodule Pleroma.Workers.Cron.ClearOauthTokenWorkerTest do
import Pleroma.Factory import Pleroma.Factory
alias Pleroma.Workers.Cron.ClearOauthTokenWorker alias Pleroma.Workers.Cron.ClearOauthTokenWorker
clear_config([:oauth2, :clean_expired_tokens]) setup do: clear_config([:oauth2, :clean_expired_tokens])
test "deletes expired tokens" do test "deletes expired tokens" do
insert(:oauth_token, insert(:oauth_token,

View File

@ -11,7 +11,7 @@ defmodule Pleroma.Workers.Cron.DigestEmailsWorkerTest do
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
clear_config([:email_notifications, :digest]) setup do: clear_config([:email_notifications, :digest])
setup do setup do
Pleroma.Config.put([:email_notifications, :digest], %{ Pleroma.Config.put([:email_notifications, :digest], %{

View File

@ -11,7 +11,7 @@ defmodule Pleroma.Workers.Cron.PurgeExpiredActivitiesWorkerTest do
import Pleroma.Factory import Pleroma.Factory
import ExUnit.CaptureLog import ExUnit.CaptureLog
clear_config([ActivityExpiration, :enabled]) setup do: clear_config([ActivityExpiration, :enabled])
test "deletes an expiration activity" do test "deletes an expiration activity" do
Pleroma.Config.put([ActivityExpiration, :enabled], true) Pleroma.Config.put([ActivityExpiration, :enabled], true)

View File

@ -11,7 +11,7 @@ defmodule Pleroma.Workers.ScheduledActivityWorkerTest do
import Pleroma.Factory import Pleroma.Factory
import ExUnit.CaptureLog import ExUnit.CaptureLog
clear_config([ScheduledActivity, :enabled]) setup do: clear_config([ScheduledActivity, :enabled])
test "creates a status from the scheduled activity" do test "creates a status from the scheduled activity" do
Pleroma.Config.put([ScheduledActivity, :enabled], true) Pleroma.Config.put([ScheduledActivity, :enabled], true)