Assorted fixes.
[akkoma] / test / web / ostatus / ostatus_test.exs
index f095e41dd1e26514603396682cee77a32269e380..6e526301481f233050f52e8a88121c6d44520824 100644 (file)
@@ -17,7 +17,7 @@ defmodule Pleroma.Web.OStatusTest do
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
 
     user = User.get_by_ap_id(activity.data["actor"])
-    assert user.info["note_count"] == 1
+    assert user.info.note_count == 1
     assert activity.data["type"] == "Create"
     assert activity.data["object"]["type"] == "Note"
 
@@ -319,7 +319,7 @@ defmodule Pleroma.Web.OStatusTest do
       assert user.name == "Constance Variable"
       assert user.nickname == "lambadalambda@social.heldscal.la"
       assert user.local == false
-      assert user.info["uri"] == uri
+      assert user.info.uri == uri
       assert user.ap_id == uri
       assert user.bio == "Call me Deacon Blues."
       assert user.avatar["type"] == "Image"
@@ -447,7 +447,7 @@ defmodule Pleroma.Web.OStatusTest do
     end
   end
 
-  test "it doesn't add nil in the do field" do
+  test "it doesn't add nil in the to field" do
     incoming = File.read!("test/fixtures/nil_mention_entry.xml")
     {:ok, [activity]} = OStatus.handle_incoming(incoming)
 
@@ -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