summaryrefslogtreecommitdiff
path: root/test/web/ostatus/feed_representer_test.exs
diff options
context:
space:
mode:
authordtluna <dtluna@openmailbox.org>2017-04-28 16:06:57 +0300
committerdtluna <dtluna@openmailbox.org>2017-04-28 16:06:57 +0300
commita9b2ad17596d1b6deca646239a95e94dc644ebf3 (patch)
tree9e086441831f33e191cd62b05b61ece0677491cc /test/web/ostatus/feed_representer_test.exs
parent28b203d08fe2e0d7afe3f3ec03a16cef62288b23 (diff)
parentfb5cebc1b5dcfd6af7fa1a81bc5b26275714fa26 (diff)
downloadpleroma-a9b2ad17596d1b6deca646239a95e94dc644ebf3.tar.gz
pleroma-a9b2ad17596d1b6deca646239a95e94dc644ebf3.zip
Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma into feature/unfollow-activity
Diffstat (limited to 'test/web/ostatus/feed_representer_test.exs')
-rw-r--r--test/web/ostatus/feed_representer_test.exs45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/web/ostatus/feed_representer_test.exs b/test/web/ostatus/feed_representer_test.exs
new file mode 100644
index 000000000..9a02d8c16
--- /dev/null
+++ b/test/web/ostatus/feed_representer_test.exs
@@ -0,0 +1,45 @@
+defmodule Pleroma.Web.OStatus.FeedRepresenterTest do
+ use Pleroma.DataCase
+ import Pleroma.Factory
+ alias Pleroma.User
+ alias Pleroma.Web.OStatus.{FeedRepresenter, UserRepresenter, ActivityRepresenter}
+ alias Pleroma.Web.OStatus
+
+ test "returns a feed of the last 20 items of the user" do
+ note_activity = insert(:note_activity)
+ user = User.get_cached_by_ap_id(note_activity.data["actor"])
+
+ tuple = FeedRepresenter.to_simple_form(user, [note_activity], [user])
+
+ most_recent_update = note_activity.updated_at
+ |> NaiveDateTime.to_iso8601
+
+ res = :xmerl.export_simple_content(tuple, :xmerl_xml) |> to_string
+ user_xml = UserRepresenter.to_simple_form(user)
+ |> :xmerl.export_simple_content(:xmerl_xml)
+
+ entry_xml = ActivityRepresenter.to_simple_form(note_activity, user)
+ |> :xmerl.export_simple_content(:xmerl_xml)
+
+ expected = """
+ <feed xmlns="http://www.w3.org/2005/Atom" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0">
+ <id>#{OStatus.feed_path(user)}</id>
+ <title>#{user.nickname}'s timeline</title>
+ <updated>#{most_recent_update}</updated>
+ <link rel="hub" href="#{OStatus.pubsub_path(user)}" />
+ <link rel="self" href="#{OStatus.feed_path(user)}" />
+ <author>
+ #{user_xml}
+ </author>
+ <entry>
+ #{entry_xml}
+ </entry>
+ </feed>
+ """
+ assert clean(res) == clean(expected)
+ end
+
+ defp clean(string) do
+ String.replace(string, ~r/\s/, "")
+ end
+end