X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Ftwitter_api%2Fviews%2Factivity_view_test.exs;h=43bd77f782965db1bb5a16424c5f4e5140a976e8;hb=16cb9e5f1cae84322bd7953e58b438f3b4bd8b9c;hp=a1776b3e6ccc084cbec8c54404c82200fd2aa2c2;hpb=1c3d3d0c2b6ebb4948df0b4ec085bcc4a564a126;p=akkoma
diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs
index a1776b3e6..43bd77f78 100644
--- a/test/web/twitter_api/views/activity_view_test.exs
+++ b/test/web/twitter_api/views/activity_view_test.exs
@@ -6,6 +6,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
use Pleroma.DataCase
alias Pleroma.Activity
+ alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
@@ -90,16 +91,16 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
test "a create activity with a summary containing emoji" do
{:ok, activity} =
CommonAPI.post(insert(:user), %{
- "spoiler_text" => ":woollysocks: meow",
+ "spoiler_text" => ":firefox: meow",
"status" => "."
})
result = ActivityView.render("activity.json", activity: activity)
- expected = ":woollysocks: meow"
+ expected = ":firefox: meow"
expected_html =
- " meow"
+ " meow"
assert result["summary"] == expected
assert result["summary_html"] == expected_html
@@ -125,10 +126,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
other_user = insert(:user, %{nickname: "shp"})
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"})
+ object = Object.normalize(activity.data["object"])
result = ActivityView.render("activity.json", activity: activity)
- convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
+ convo_id = Utils.context_to_conversation_id(object.data["context"])
expected = %{
"activity_type" => "post",
@@ -136,8 +138,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
"attentions" => [
UserView.render("show.json", %{user: other_user})
],
- "created_at" => activity.data["object"]["published"] |> Utils.date_to_asctime(),
- "external_url" => activity.data["object"]["id"],
+ "created_at" => object.data["published"] |> Utils.date_to_asctime(),
+ "external_url" => object.data["id"],
"fave_num" => 0,
"favorited" => false,
"id" => activity.id,
@@ -161,7 +163,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
}\">@shp!",
"tags" => [],
"text" => "Hey @shp!",
- "uri" => activity.data["object"]["id"],
+ "uri" => object.data["id"],
"user" => UserView.render("show.json", %{user: user}),
"visibility" => "direct",
"card" => nil,
@@ -175,8 +177,9 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
user = insert(:user)
other_user = insert(:user, %{nickname: "shp"})
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
+ object = Object.normalize(activity.data["object"])
- convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
+ convo_id = Utils.context_to_conversation_id(object.data["context"])
mocks = [
{
@@ -277,11 +280,11 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
other_user = insert(:user, %{nickname: "shp"})
{:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
- {:ok, announce, _object} = CommonAPI.repeat(activity.id, other_user)
+ {:ok, announce, object} = CommonAPI.repeat(activity.id, other_user)
- convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
+ convo_id = Utils.context_to_conversation_id(object.data["context"])
- activity = Repo.get(Activity, activity.id)
+ activity = Activity.get_by_id(activity.id)
result = ActivityView.render("activity.json", activity: announce)
@@ -292,8 +295,8 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
"id" => announce.id,
"is_local" => true,
"is_post_verb" => false,
- "statusnet_html" => "shp retweeted a status.",
- "text" => "shp retweeted a status.",
+ "statusnet_html" => "shp repeated a status.",
+ "text" => "shp repeated a status.",
"uri" => "tag:#{announce.data["id"]}:objectType=note",
"user" => UserView.render("show.json", user: other_user),
"retweeted_status" => ActivityView.render("activity.json", activity: activity),
@@ -357,7 +360,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
test "a peertube video" do
{:ok, object} =
- ActivityPub.fetch_object_from_id(
+ Pleroma.Object.Fetcher.fetch_object_from_id(
"https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3"
)
@@ -368,4 +371,14 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
assert length(result["attachments"]) == 1
assert result["summary"] == "Friday Night"
end
+
+ test "special characters are not escaped in text field for status created" do
+ text = "<3 is on the way"
+
+ {:ok, activity} = CommonAPI.post(insert(:user), %{"status" => text})
+
+ result = ActivityView.render("activity.json", activity: activity)
+
+ assert result["text"] == text
+ end
end