1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.OStatus.FeedRepresenterTest do
9 alias Pleroma.Web.OStatus.{FeedRepresenter, UserRepresenter, ActivityRepresenter}
10 alias Pleroma.Web.OStatus
12 test "returns a feed of the last 20 items of the user" do
13 note_activity = insert(:note_activity)
14 user = User.get_cached_by_ap_id(note_activity.data["actor"])
16 tuple = FeedRepresenter.to_simple_form(user, [note_activity], [user])
19 note_activity.updated_at
20 |> NaiveDateTime.to_iso8601()
22 res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
25 UserRepresenter.to_simple_form(user)
26 |> :xmerl.export_simple_content(:xmerl_xml)
29 ActivityRepresenter.to_simple_form(note_activity, user)
30 |> :xmerl.export_simple_content(:xmerl_xml)
33 <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">
34 <id>#{OStatus.feed_path(user)}</id>
35 <title>#{user.nickname}'s timeline</title>
36 <updated>#{most_recent_update}</updated>
37 <logo>#{User.avatar_url(user)}</logo>
38 <link rel="hub" href="#{OStatus.pubsub_path(user)}" />
39 <link rel="salmon" href="#{OStatus.salmon_path(user)}" />
40 <link rel="self" href="#{OStatus.feed_path(user)}" type="application/atom+xml" />
44 <link rel="next" href="#{OStatus.feed_path(user)}?max_id=#{note_activity.id}" type="application/atom+xml" />
51 assert clean(res) == clean(expected)
55 String.replace(string, ~r/\s/, "")