Merge branch 'develop' into dtluna/pleroma-feature/unfollow-activity
[akkoma] / test / web / twitter_api / twitter_api_test.exs
index 57dcddd4c16de7a71a64395f7d50743486d37d76..9a7dc48dab42e472cd90e1413f21b8dd8509eb37 100644 (file)
@@ -33,7 +33,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
 
     { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
 
-    assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.<br>This is on another line."
+    assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.<br>This is on another line.<br><a href='http://example.org/image.jpg'>http://example.org/image.jpg</a>"
     assert get_in(activity.data, ["object", "type"]) == "Note"
     assert get_in(activity.data, ["object", "actor"]) == user.ap_id
     assert get_in(activity.data, ["actor"]) == user.ap_id
@@ -73,8 +73,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     assert Enum.member?(get_in(reply.data, ["to"]), "some_cool_id")
   end
 
-  test "fetch public statuses" do
+  test "fetch public statuses, excluding remote ones." do
     %{ public: activity, user: user } = ActivityBuilder.public_and_non_public
+    insert(:note_activity, %{local: false})
 
     follower = insert(:user, following: [User.ap_followers(user)])
 
@@ -84,6 +85,18 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: user, for: follower})
   end
 
+  test "fetch whole known network statuses" do
+    %{ public: activity, user: user } = ActivityBuilder.public_and_non_public
+    insert(:note_activity, %{local: false})
+
+    follower = insert(:user, following: [User.ap_followers(user)])
+
+    statuses = TwitterAPI.fetch_public_and_external_statuses(follower)
+
+    assert length(statuses) == 2
+    assert Enum.at(statuses, 0) == ActivityRepresenter.to_map(activity, %{user: user, for: follower})
+  end
+
   test "fetch friends' statuses" do
     user = insert(:user, %{following: ["someguy/followers"]})
     {:ok, activity} = ActivityBuilder.insert(%{"to" => ["someguy/followers"]})
@@ -177,6 +190,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
   test "Unfollow another user using user_id" do
     unfollowed = insert(:user)
     user = insert(:user, %{following: [User.ap_followers(unfollowed)]})
+    ActivityPub.follow(user, unfollowed)
 
     {:ok, user, unfollowed } = TwitterAPI.unfollow(user, %{"user_id" => unfollowed.id})
     assert user.following == []
@@ -189,6 +203,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     unfollowed = insert(:user)
     user = insert(:user, %{following: [User.ap_followers(unfollowed)]})
 
+    ActivityPub.follow(user, unfollowed)
+
     {:ok, user, unfollowed } = TwitterAPI.unfollow(user, %{"screen_name" => unfollowed.nickname})
     assert user.following == []