improve test
authorhakabahitoyo <hakabahitoyo@example.com>
Fri, 20 Jul 2018 17:57:56 +0000 (02:57 +0900)
committerhakabahitoyo <hakabahitoyo@example.com>
Fri, 20 Jul 2018 17:57:56 +0000 (02:57 +0900)
test/support/factory.ex
test/web/activity_pub/activity_pub_controller_test.exs

index b2e98c8d108e6e2ebc8c7047290760bd3a5d978d..e9b4beb7d6947e2ed848c5ca7d2688e9fbecd4ed 100644 (file)
@@ -65,6 +65,26 @@ defmodule Pleroma.Factory do
     }
   end
 
+  def announce_activity_factory do
+    note_activity = insert(:note_activity)
+    user = insert(:user)
+
+    data = %{
+      "type" => "Announce",
+      "actor" => note_activity.actor,
+      "object" => note_activity.data["id"],
+      "to" => [user.follower_address, note_activity.data["actor"]],
+      "cc" => ["https://www.w3.org/ns/activitystreams#Public"],
+      "context" => note_activity.data["context"]
+    }
+
+    %Pleroma.Activity{
+      data: data,
+      actor: user.ap_id,
+      recipients: data["to"]
+    }
+  end
+
   def like_activity_factory do
     note_activity = insert(:note_activity)
     user = insert(:user)
index 1daa5627c008f6883c77a6f8c10c178a7272075b..8a1c0d361e96e5fe78addb29fc5d463a99579514 100644 (file)
@@ -51,7 +51,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
   end
 
   describe "/users/:nickname/outbox" do
-    test "it returns a note action in a collection", %{conn: conn} do
+    test "it returns a note activity in a collection", %{conn: conn} do
       note_activity = insert(:note_activity)
       user = User.get_cached_by_ap_id(note_activity.data["actor"])
 
@@ -62,6 +62,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
 
       assert response(conn, 200) =~ note_activity.data["object"]["content"]
     end
+
+    test "it returns an announce activity in a collection", %{conn: conn} do
+      announce_activity = insert(:announce_activity)
+      user = User.get_cached_by_ap_id(announce_activity.data["actor"])
+
+      conn =
+        conn
+        |> put_req_header("accept", "application/activity+json")
+        |> get("/users/#{user.nickname}/outbox")
+
+      assert response(conn, 200) =~ announce_activity.data["object"]
+    end
   end
 
   describe "/users/:nickname/followers" do