summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLain Iwakura <lain@soykaf.club>2017-12-11 18:22:48 +0100
committerLain Iwakura <lain@soykaf.club>2017-12-11 18:22:48 +0100
commite2e636503525f4e295430ddb71007ab8e851e856 (patch)
tree05872aea9cf34e79872524d83326ee83820dc0bd
parent64330d9455684e417d014cb6f21ce7f52620b9db (diff)
downloadpleroma-e2e636503525f4e295430ddb71007ab8e851e856.tar.gz
pleroma-e2e636503525f4e295430ddb71007ab8e851e856.zip
ActivityPub: Add controller tests.
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
new file mode 100644
index 000000000..21ed28cf2
--- /dev/null
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -0,0 +1,39 @@
+defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
+ use Pleroma.Web.ConnCase
+ import Pleroma.Factory
+ alias Pleroma.Web.ActivityPub.{UserView, ObjectView}
+ alias Pleroma.{Repo, User}
+
+ describe "/users/:nickname" do
+ test "it returns a json representation of the user", %{conn: conn} do
+ user = insert(:user)
+
+ conn = conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get("/users/#{user.nickname}")
+
+ user = Repo.get(User, user.id)
+
+ assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
+ end
+ end
+
+ describe "/object/:uuid" do
+ test "it returns a json representation of the object", %{conn: conn} do
+ note = insert(:note)
+ uuid = String.split(note.data["id"], "/") |> List.last
+
+ conn = conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get("/objects/#{uuid}")
+
+ assert json_response(conn, 200) == ObjectView.render("object.json", %{object: note})
+ end
+ end
+
+ describe "/users/:nickname/inbox" do
+ test "it inserts an incoming activity into the database" do
+ assert false
+ end
+ end
+end