X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fo_status%2Fo_status_controller_test.exs;h=81d66983763b1f879775d0ab1aaeafaaddc5f68f;hb=51a9f97e87823cbd9e92c375f4bc4c0bfa8b79db;hp=65b2c22dbe45bb16ac9a5335f5a3f5ae8675603d;hpb=a65fc78c6a14e1333ce71d28824a490a8a6da69b;p=akkoma diff --git a/test/pleroma/web/o_status/o_status_controller_test.exs b/test/pleroma/web/o_status/o_status_controller_test.exs index 65b2c22db..81d669837 100644 --- a/test/pleroma/web/o_status/o_status_controller_test.exs +++ b/test/pleroma/web/o_status/o_status_controller_test.exs @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.OStatus.OStatusControllerTest do @@ -72,7 +72,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do test "redirects to /notice/id for html format", %{conn: conn} do note_activity = insert(:note_activity) - object = Object.normalize(note_activity) + object = Object.normalize(note_activity, fetch: false) [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"])) url = "/objects/#{uuid}" @@ -82,7 +82,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do test "404s on private objects", %{conn: conn} do note_activity = insert(:direct_note_activity) - object = Object.normalize(note_activity) + object = Object.normalize(note_activity, fetch: false) [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, object.data["id"])) conn @@ -133,7 +133,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do conn: conn } do note_activity = insert(:note_activity) - expected_redirect_url = Object.normalize(note_activity).data["id"] + expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"] redirect_url = conn @@ -144,13 +144,19 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do assert redirect_url == expected_redirect_url end - test "returns a 404 on remote notice when json requested", %{conn: conn} do + test "redirects to a proper object URL when json requested and the object is remote", %{ + conn: conn + } do note_activity = insert(:note_activity, local: false) + expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"] - conn - |> put_req_header("accept", "application/activity+json") - |> get("/notice/#{note_activity.id}") - |> response(404) + redirect_url = + conn + |> put_req_header("accept", "application/activity+json") + |> get("/notice/#{note_activity.id}") + |> redirected_to() + + assert redirect_url == expected_redirect_url end test "500s when actor not found", %{conn: conn} do @@ -176,7 +182,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do |> response(200) assert resp =~ - "" + "" user = insert(:user) @@ -230,7 +236,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do describe "GET /notice/:id/embed_player" do setup do note_activity = insert(:note_activity) - object = Pleroma.Object.normalize(note_activity) + object = Pleroma.Object.normalize(note_activity, fetch: false) object_data = Map.put(object.data, "attachment", [ @@ -287,7 +293,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do test "404s when attachment is empty", %{conn: conn} do note_activity = insert(:note_activity) - object = Pleroma.Object.normalize(note_activity) + object = Pleroma.Object.normalize(note_activity, fetch: false) object_data = Map.put(object.data, "attachment", []) object @@ -301,7 +307,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do test "404s when attachment isn't audio or video", %{conn: conn} do note_activity = insert(:note_activity) - object = Pleroma.Object.normalize(note_activity) + object = Pleroma.Object.normalize(note_activity, fetch: false) object_data = Map.put(object.data, "attachment", [