summaryrefslogtreecommitdiff
path: root/test/web/twitter_api
diff options
context:
space:
mode:
authordtluna <dtluna@openmailbox.org>2017-04-13 15:36:00 +0300
committerdtluna <dtluna@openmailbox.org>2017-04-13 15:36:00 +0300
commita8e50d602ba25b2062e0e676e1dd115da64c2565 (patch)
tree4921704448e03286876255b0aa0b46badf58e586 /test/web/twitter_api
parent65ef18a7157f8cfcc494ad7a72ce083e79e38d26 (diff)
parentd2bf099ae66b7332128c854f322bb8a00eb62212 (diff)
downloadpleroma-a8e50d602ba25b2062e0e676e1dd115da64c2565.tar.gz
pleroma-a8e50d602ba25b2062e0e676e1dd115da64c2565.zip
Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma into bugfix/repeated-follow-unfollow
Diffstat (limited to 'test/web/twitter_api')
-rw-r--r--test/web/twitter_api/representers/activity_representer_test.exs11
-rw-r--r--test/web/twitter_api/twitter_api_controller_test.exs4
-rw-r--r--test/web/twitter_api/twitter_api_test.exs5
3 files changed, 12 insertions, 8 deletions
diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs
index 256d920c0..f1f2b4c9c 100644
--- a/test/web/twitter_api/representers/activity_representer_test.exs
+++ b/test/web/twitter_api/representers/activity_representer_test.exs
@@ -23,8 +23,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
}
}
- content = "Some content mentioning @shp"
- date = DateTime.utc_now() |> DateTime.to_iso8601
+ content_html = "Some content mentioning <a href='shp'>@shp</shp>"
+ content = HtmlSanitizeEx.strip_tags(content_html)
+ date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601
activity = %Activity{
id: 1,
@@ -39,7 +40,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"object" => %{
"published" => date,
"type" => "Note",
- "content" => content,
+ "content" => content_html,
"inReplyToStatusId" => 213123,
"statusnetConversationId" => 4711,
"attachment" => [
@@ -56,10 +57,10 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"user" => UserRepresenter.to_map(user, %{for: follower}),
"is_local" => true,
"attentions" => [],
- "statusnet_html" => content,
+ "statusnet_html" => content_html,
"text" => content,
"is_post_verb" => true,
- "created_at" => date,
+ "created_at" => "Tue May 24 13:26:08 +0000 2016",
"in_reply_to_status_id" => 213123,
"statusnet_conversation_id" => 4711,
"attachments" => [
diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs
index 5aad12593..7c75ff757 100644
--- a/test/web/twitter_api/twitter_api_controller_test.exs
+++ b/test/web/twitter_api/twitter_api_controller_test.exs
@@ -127,7 +127,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
current_user = Repo.get(User, current_user.id)
assert current_user.following == [User.ap_followers(followed)]
- assert json_response(conn, 200) == UserRepresenter.to_map(followed)
+ assert json_response(conn, 200) == UserRepresenter.to_map(followed, %{for: current_user})
end
end
@@ -150,7 +150,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
current_user = Repo.get(User, current_user.id)
assert current_user.following == []
- assert json_response(conn, 200) == UserRepresenter.to_map(followed)
+ assert json_response(conn, 200) == UserRepresenter.to_map(followed, %{for: current_user})
end
end
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index c1f5881b8..405aa1221 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -82,15 +82,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
test "fetch friends' statuses" do
ActivityBuilder.public_and_non_public
+
{:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]})
+ {:ok, direct_activity} = ActivityBuilder.insert(%{"to" => ["some other id"]})
{:ok, user} = UserBuilder.insert(%{ap_id: "some other id", following: ["someguy/followers"]})
statuses = TwitterAPI.fetch_friend_statuses(user)
activity_user = Repo.get_by(User, ap_id: activity.data["actor"])
- assert length(statuses) == 1
+ assert length(statuses) == 2
assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: activity_user})
+ assert Enum.at(statuses, 1) == ActivityRepresenter.to_map(direct_activity, %{user: activity_user, mentioned: [user]})
end
test "fetch a single status" do