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.Feed.TagControllerTest do
6 use Pleroma.Web.ConnCase
11 alias Pleroma.Web.Feed.FeedView
15 test "gets a feed", %{conn: conn} do
18 %{max_length: 25, omission: "..."}
22 {:ok, activity1} = Pleroma.Web.CommonAPI.post(user, %{"status" => "yeah #PleromaArt"})
24 object = Pleroma.Object.normalize(activity1)
27 Map.put(object.data, "attachment", [
32 "https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4",
33 "mediaType" => "video/mp4",
41 |> Ecto.Changeset.change(data: object_data)
42 |> Pleroma.Repo.update()
45 Pleroma.Web.CommonAPI.post(user, %{"status" => "42 This is :moominmamma #PleromaArt"})
47 {:ok, _activity3} = Pleroma.Web.CommonAPI.post(user, %{"status" => "This is :moominmamma"})
51 |> put_req_header("content-type", "application/atom+xml")
52 |> get(tag_feed_path(conn, :feed, "pleromaart.rss"))
56 assert xpath(xml, ~x"//channel/title/text()") == '#pleromaart'
58 assert xpath(xml, ~x"//channel/description/text()"s) ==
59 "These are public toots tagged with #pleromaart. You can interact with them if you have an account anywhere in the fediverse."
61 assert xpath(xml, ~x"//channel/link/text()") ==
62 '#{Pleroma.Web.base_url()}/tags/pleromaart.rss'
64 assert xpath(xml, ~x"//channel/webfeeds:logo/text()") ==
65 '#{Pleroma.Web.base_url()}/static/logo.png'
67 assert xpath(xml, ~x"//channel/item/title/text()"l) == [
68 '42 This is :moominmamm...',
72 assert xpath(xml, ~x"//channel/item/pubDate/text()"sl) == [
73 FeedView.pub_date(activity1.data["published"]),
74 FeedView.pub_date(activity2.data["published"])
77 assert xpath(xml, ~x"//channel/item/enclosure/@url"sl) == [
78 "https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4"
81 obj1 = Pleroma.Object.normalize(activity1)
82 obj2 = Pleroma.Object.normalize(activity2)
84 assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
85 HtmlEntities.decode(FeedView.activity_content(obj2)),
86 HtmlEntities.decode(FeedView.activity_content(obj1))
91 |> put_req_header("content-type", "application/atom+xml")
92 |> get(tag_feed_path(conn, :feed, "pleromaart"))
96 assert xpath(xml, ~x"//channel/title/text()") == '#pleromaart'
98 assert xpath(xml, ~x"//channel/description/text()"s) ==
99 "These are public toots tagged with #pleromaart. You can interact with them if you have an account anywhere in the fediverse."