1 defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
2 use Pleroma.Web.ConnCase
4 alias Pleroma.Web.ActivityPub.{UserView, ObjectView}
5 alias Pleroma.{Repo, User}
8 describe "/users/:nickname" do
9 test "it returns a json representation of the user", %{conn: conn} do
14 |> put_req_header("accept", "application/activity+json")
15 |> get("/users/#{user.nickname}")
17 user = Repo.get(User, user.id)
19 assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
23 describe "/object/:uuid" do
24 test "it returns a json representation of the object", %{conn: conn} do
26 uuid = String.split(note.data["id"], "/") |> List.last()
30 |> put_req_header("accept", "application/activity+json")
31 |> get("/objects/#{uuid}")
33 assert json_response(conn, 200) == ObjectView.render("object.json", %{object: note})
37 describe "/users/:nickname/inbox" do
38 test "it inserts an incoming activity into the database", %{conn: conn} do
39 data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
43 |> assign(:valid_signature, true)
44 |> put_req_header("content-type", "application/activity+json")
45 |> post("/inbox", data)
47 assert "ok" == json_response(conn, 200)
49 assert Activity.get_by_ap_id(data["id"])