Also fetch atom links.
[akkoma] / test / web / ostatus / ostatus_controller_test.exs
1 defmodule Pleroma.Web.OStatus.OStatusControllerTest do
2 use Pleroma.Web.ConnCase
3 import Pleroma.Factory
4 alias Pleroma.User
5 alias Pleroma.Web.OStatus.ActivityRepresenter
6
7 test "gets a feed", %{conn: conn} do
8 note_activity = insert(:note_activity)
9 user = User.get_cached_by_ap_id(note_activity.data["actor"])
10
11 conn = conn
12 |> get("/users/#{user.nickname}/feed.atom")
13
14 assert response(conn, 200)
15 end
16
17 test "gets an object", %{conn: conn} do
18 note_activity = insert(:note_activity)
19 user = User.get_by_ap_id(note_activity.data["actor"])
20 [_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])
21 url = "/objects/#{uuid}"
22
23 conn = conn
24 |> get(url)
25
26 expected = ActivityRepresenter.to_simple_form(note_activity, user, true)
27 |> ActivityRepresenter.wrap_with_entry
28 |> :xmerl.export_simple(:xmerl_xml)
29 |> to_string
30
31 assert response(conn, 200) == expected
32 end
33
34 test "gets an activity", %{conn: conn} do
35 note_activity = insert(:note_activity)
36 [_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])
37 url = "/activities/#{uuid}"
38
39 conn = conn
40 |> get(url)
41
42 assert response(conn, 200)
43 end
44 end