Save follower count and note count in user.
[akkoma] / test / web / ostatus / ostatus_controller_test.exs
index 229cd9b1e1c214980eafdb8b00f4e6e4df8ce7bd..77bc202fefccaf29e7caec4a73ebdd03ca1f3613 100644 (file)
@@ -2,6 +2,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
   use Pleroma.Web.ConnCase
   import Pleroma.Factory
   alias Pleroma.User
+  alias Pleroma.Web.OStatus.ActivityRepresenter
 
   test "gets a feed", %{conn: conn} do
     note_activity = insert(:note_activity)
@@ -12,4 +13,32 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
 
     assert response(conn, 200)
   end
+
+  test "gets an object", %{conn: conn} do
+    note_activity = insert(:note_activity)
+    user = User.get_by_ap_id(note_activity.data["actor"])
+    [_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])
+    url = "/objects/#{uuid}"
+
+    conn = conn
+    |> get(url)
+
+    expected = ActivityRepresenter.to_simple_form(note_activity, user, true)
+    |> ActivityRepresenter.wrap_with_entry
+    |> :xmerl.export_simple(:xmerl_xml)
+    |> to_string
+
+    assert response(conn, 200) == expected
+  end
+
+  test "gets an activity", %{conn: conn} do
+    note_activity = insert(:note_activity)
+    [_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])
+    url = "/activities/#{uuid}"
+
+    conn = conn
+    |> get(url)
+
+    assert response(conn, 200)
+  end
 end