Remove the debugging IO.inspect
[akkoma] / test / web / ostatus / feed_representer_test.exs
1 defmodule Pleroma.Web.OStatus.FeedRepresenterTest do
2 use Pleroma.DataCase
3 import Pleroma.Factory
4 alias Pleroma.User
5 alias Pleroma.Web.OStatus.{FeedRepresenter, UserRepresenter, ActivityRepresenter}
6 alias Pleroma.Web.OStatus
7
8 test "returns a feed of the last 20 items of the user" do
9 note_activity = insert(:note_activity)
10 user = User.get_cached_by_ap_id(note_activity.data["actor"])
11
12 tuple = FeedRepresenter.to_simple_form(user, [note_activity], [user])
13
14 most_recent_update =
15 note_activity.updated_at
16 |> NaiveDateTime.to_iso8601()
17
18 res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
19
20 user_xml =
21 UserRepresenter.to_simple_form(user)
22 |> :xmerl.export_simple_content(:xmerl_xml)
23
24 entry_xml =
25 ActivityRepresenter.to_simple_form(note_activity, user)
26 |> :xmerl.export_simple_content(:xmerl_xml)
27
28 expected = """
29 <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0">
30 <id>#{OStatus.feed_path(user)}</id>
31 <title>#{user.nickname}'s timeline</title>
32 <updated>#{most_recent_update}</updated>
33 <logo>#{User.avatar_url(user)}</logo>
34 <link rel="hub" href="#{OStatus.pubsub_path(user)}" />
35 <link rel="salmon" href="#{OStatus.salmon_path(user)}" />
36 <link rel="self" href="#{OStatus.feed_path(user)}" type="application/atom+xml" />
37 <author>
38 #{user_xml}
39 </author>
40 <link rel="next" href="#{OStatus.feed_path(user)}?max_id=#{note_activity.id}" type="application/atom+xml" />
41 <entry>
42 #{entry_xml}
43 </entry>
44 </feed>
45 """
46
47 assert clean(res) == clean(expected)
48 end
49
50 defp clean(string) do
51 String.replace(string, ~r/\s/, "")
52 end
53 end