summaryrefslogtreecommitdiff
path: root/test/web/ostatus
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2018-12-01 18:12:27 +0300
committerrinpatch <rinpatch@sdf.org>2018-12-01 18:12:27 +0300
commitfe2759bc9f2dad044b49f4954693ac09f9368041 (patch)
tree59dd9c5026f433d976defa303de0d6782d435d1e /test/web/ostatus
parentba6e3eba33f16bdd2fede086d5fb5c86201cb57b (diff)
parent8c3ff06e35e11a40cf4eb35a41a2019b7496e62c (diff)
downloadpleroma-fe2759bc9f2dad044b49f4954693ac09f9368041.tar.gz
pleroma-fe2759bc9f2dad044b49f4954693ac09f9368041.zip
Attempt to resolve merge conflict
Diffstat (limited to 'test/web/ostatus')
-rw-r--r--test/web/ostatus/ostatus_controller_test.exs27
-rw-r--r--test/web/ostatus/ostatus_test.exs24
2 files changed, 51 insertions, 0 deletions
diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs
index c23b175e8..371c835c0 100644
--- a/test/web/ostatus/ostatus_controller_test.exs
+++ b/test/web/ostatus/ostatus_controller_test.exs
@@ -2,6 +2,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
use Pleroma.Web.ConnCase
import Pleroma.Factory
alias Pleroma.{User, Repo}
+ alias Pleroma.Web.CommonAPI
alias Pleroma.Web.OStatus.ActivityRepresenter
test "decodes a salmon", %{conn: conn} do
@@ -167,6 +168,32 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert json_response(conn, 200)
end
+ test "only gets a notice in AS2 format for Create messages", %{conn: conn} do
+ note_activity = insert(:note_activity)
+ url = "/notice/#{note_activity.id}"
+
+ conn =
+ conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get(url)
+
+ assert json_response(conn, 200)
+
+ user = insert(:user)
+
+ {:ok, like_activity, _} = CommonAPI.favorite(note_activity.id, user)
+ url = "/notice/#{like_activity.id}"
+
+ assert like_activity.data["type"] == "Like"
+
+ conn =
+ build_conn()
+ |> put_req_header("accept", "application/activity+json")
+ |> get(url)
+
+ assert response(conn, 404)
+ end
+
test "gets an activity in AS2 format", %{conn: conn} do
note_activity = insert(:note_activity)
[_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"]))
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index f095e41dd..f95da8b0a 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -456,4 +456,28 @@ defmodule Pleroma.Web.OStatusTest do
"https://www.w3.org/ns/activitystreams#Public"
]
end
+
+ describe "is_representable?" do
+ test "Note objects are representable" do
+ note_activity = insert(:note_activity)
+
+ assert OStatus.is_representable?(note_activity)
+ end
+
+ test "Article objects are not representable" do
+ note_activity = insert(:note_activity)
+
+ note_object = Object.normalize(note_activity.data["object"])
+
+ note_data =
+ note_object.data
+ |> Map.put("type", "Article")
+
+ cs = Object.change(note_object, %{data: note_data})
+ {:ok, article_object} = Repo.update(cs)
+
+ # the underlying object is now an Article instead of a note, so this should fail
+ refute OStatus.is_representable?(note_activity)
+ end
+ end
end