X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fpreload%2Ftimeline_test.exs;h=3b1f2f1aa17b357e807c8e8c3dee5895d102c724;hb=9c672ecbb5d4477cd16d2139a2cb66d3923ac5c8;hp=00b10d0abbab3f10db5815d00ef518a774f08a9f;hpb=29ae5bb77166d9d7f8108a965b0c3d147b747e80;p=akkoma diff --git a/test/web/preload/timeline_test.exs b/test/web/preload/timeline_test.exs index 00b10d0ab..3b1f2f1aa 100644 --- a/test/web/preload/timeline_test.exs +++ b/test/web/preload/timeline_test.exs @@ -9,19 +9,11 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do alias Pleroma.Web.CommonAPI alias Pleroma.Web.Preload.Providers.Timelines - @public_url :"/api/v1/timelines/public" + @public_url "/api/v1/timelines/public" describe "unauthenticated timeliness when restricted" do - setup do - svd_config = Pleroma.Config.get([:restrict_unauthenticated, :timelines]) - Pleroma.Config.put([:restrict_unauthenticated, :timelines], %{local: true, federated: true}) - - on_exit(fn -> - Pleroma.Config.put([:restrict_unauthenticated, :timelines], svd_config) - end) - - :ok - end + setup do: clear_config([:restrict_unauthenticated, :timelines, :local], true) + setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], true) test "return nothing" do tl_data = Timelines.generate_terms(%{}) @@ -31,20 +23,10 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do end describe "unauthenticated timeliness when unrestricted" do - setup do - svd_config = Pleroma.Config.get([:restrict_unauthenticated, :timelines]) + setup do: clear_config([:restrict_unauthenticated, :timelines, :local], false) + setup do: clear_config([:restrict_unauthenticated, :timelines, :federated], false) - Pleroma.Config.put([:restrict_unauthenticated, :timelines], %{ - local: false, - federated: false - }) - - on_exit(fn -> - Pleroma.Config.put([:restrict_unauthenticated, :timelines], svd_config) - end) - - {:ok, user: insert(:user)} - end + setup do: {:ok, user: insert(:user)} test "returns the timeline when not restricted" do assert Timelines.generate_terms(%{}) @@ -52,9 +34,9 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do end test "returns public items", %{user: user} do - {:ok, _} = CommonAPI.post(user, %{"status" => "it's post 1!"}) - {:ok, _} = CommonAPI.post(user, %{"status" => "it's post 2!"}) - {:ok, _} = CommonAPI.post(user, %{"status" => "it's post 3!"}) + {:ok, _} = CommonAPI.post(user, %{status: "it's post 1!"}) + {:ok, _} = CommonAPI.post(user, %{status: "it's post 2!"}) + {:ok, _} = CommonAPI.post(user, %{status: "it's post 3!"}) assert Timelines.generate_terms(%{}) |> Map.fetch!(@public_url) @@ -62,9 +44,9 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do end test "does not return non-public items", %{user: user} do - {:ok, _} = CommonAPI.post(user, %{"status" => "it's post 1!", "visibility" => "unlisted"}) - {:ok, _} = CommonAPI.post(user, %{"status" => "it's post 2!", "visibility" => "direct"}) - {:ok, _} = CommonAPI.post(user, %{"status" => "it's post 3!"}) + {:ok, _} = CommonAPI.post(user, %{status: "it's post 1!", visibility: "unlisted"}) + {:ok, _} = CommonAPI.post(user, %{status: "it's post 2!", visibility: "direct"}) + {:ok, _} = CommonAPI.post(user, %{status: "it's post 3!"}) assert Timelines.generate_terms(%{}) |> Map.fetch!(@public_url)