From 15655d992e8ba2aa8d4680eb38a8d3039b58703a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 12 Apr 2017 16:38:55 +0200 Subject: Fix user representation after following. --- test/web/twitter_api/twitter_api_controller_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/web/twitter_api') 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 -- cgit v1.2.3 From 8eea09889b114a27eaf6ca1998b4d3ca3505ad51 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 12 Apr 2017 16:45:23 +0200 Subject: Return directly addressed activities in friends timeline. --- test/web/twitter_api/twitter_api_test.exs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index ad932131a..dcb38b8b1 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -82,14 +82,16 @@ 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}) end -- cgit v1.2.3 From 6a179a44bec113b8fb9a8092f791111a318e7a53 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 12 Apr 2017 16:53:46 +0200 Subject: Test friends timeline more thoroughly. --- test/web/twitter_api/twitter_api_test.exs | 1 + 1 file changed, 1 insertion(+) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index dcb38b8b1..e8853a910 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -93,6 +93,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do 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 -- cgit v1.2.3 From 1b086834bd83a490e55d44ffa5167c8856db92d9 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 12 Apr 2017 17:22:29 +0200 Subject: Don't return html in the text field. --- test/web/twitter_api/representers/activity_representer_test.exs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 256d920c0..6b0da810f 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -23,7 +23,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do } } - content = "Some content mentioning @shp" + content_html = "Some content mentioning @shp" + content = HtmlSanitizeEx.strip_tags(content_html) date = DateTime.utc_now() |> DateTime.to_iso8601 activity = %Activity{ @@ -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,7 +57,7 @@ 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, -- cgit v1.2.3 From d2bf099ae66b7332128c854f322bb8a00eb62212 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 12 Apr 2017 19:34:58 +0200 Subject: Fix twitter api date. --- test/web/twitter_api/representers/activity_representer_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/web/twitter_api') diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 6b0da810f..f1f2b4c9c 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -25,7 +25,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do content_html = "Some content mentioning @shp" content = HtmlSanitizeEx.strip_tags(content_html) - date = DateTime.utc_now() |> DateTime.to_iso8601 + date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601 activity = %Activity{ id: 1, @@ -60,7 +60,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do "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" => [ -- cgit v1.2.3