1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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
10 alias Pleroma.Web.OStatus.ActivityRepresenter
11 alias Pleroma.Web.OStatus.FeedRepresenter
12 alias Pleroma.Web.OStatus.UserRepresenter
14 test "returns a feed of the last 20 items of the user" do
15 note_activity = insert(:note_activity)
16 user = User.get_cached_by_ap_id(note_activity.data["actor"])
18 tuple = FeedRepresenter.to_simple_form(user, [note_activity], [user])
21 note_activity.updated_at
22 |> NaiveDateTime.to_iso8601()
24 res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
27 UserRepresenter.to_simple_form(user)
28 |> :xmerl.export_simple_content(:xmerl_xml)
31 ActivityRepresenter.to_simple_form(note_activity, user)
32 |> :xmerl.export_simple_content(:xmerl_xml)
35 <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">
36 <id>#{OStatus.feed_path(user)}</id>
37 <title>#{user.nickname}'s timeline</title>
38 <updated>#{most_recent_update}</updated>
39 <logo>#{User.avatar_url(user)}</logo>
40 <link rel="hub" href="#{OStatus.pubsub_path(user)}" />
41 <link rel="salmon" href="#{OStatus.salmon_path(user)}" />
42 <link rel="self" href="#{OStatus.feed_path(user)}" type="application/atom+xml" />
46 <link rel="next" href="#{OStatus.feed_path(user)}?max_id=#{note_activity.id}" type="application/atom+xml" />
53 assert clean(res) == clean(expected)
57 String.replace(string, ~r/\s/, "")