X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fplugs%2Fensure_public_or_authenticated_plug_test.exs;h=fc2934369b573101a209c0cc7f868ed92656ddd9;hb=fbb9743a7058e8a7ace69804b79eb032e03da078;hp=ce5d77ff7e1a973a0b7b68e6da83ab1abac4c70f;hpb=f168a1cbdc318ffaa2d8bc9fb561eb3dfdfb89d9;p=akkoma
diff --git a/test/plugs/ensure_public_or_authenticated_plug_test.exs b/test/plugs/ensure_public_or_authenticated_plug_test.exs
index ce5d77ff7..fc2934369 100644
--- a/test/plugs/ensure_public_or_authenticated_plug_test.exs
+++ b/test/plugs/ensure_public_or_authenticated_plug_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlugTest do
@@ -9,8 +9,10 @@ defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlugTest do
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
alias Pleroma.User
+ setup do: clear_config([:instance, :public])
+
test "it halts if not public and no user is assigned", %{conn: conn} do
- set_public_to(false)
+ Config.put([:instance, :public], false)
conn =
conn
@@ -21,17 +23,17 @@ defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlugTest do
end
test "it continues if public", %{conn: conn} do
- set_public_to(true)
+ Config.put([:instance, :public], true)
ret_conn =
conn
|> EnsurePublicOrAuthenticatedPlug.call(%{})
- assert ret_conn == conn
+ refute ret_conn.halted
end
test "it continues if a user is assigned, even if not public", %{conn: conn} do
- set_public_to(false)
+ Config.put([:instance, :public], false)
conn =
conn
@@ -41,15 +43,6 @@ defmodule Pleroma.Plugs.EnsurePublicOrAuthenticatedPlugTest do
conn
|> EnsurePublicOrAuthenticatedPlug.call(%{})
- assert ret_conn == conn
- end
-
- defp set_public_to(value) do
- orig = Config.get!([:instance, :public])
- Config.put([:instance, :public], value)
-
- on_exit(fn ->
- Config.put([:instance, :public], orig)
- end)
+ refute ret_conn.halted
end
end