X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fostatus%2Fostatus_test.exs;h=6e526301481f233050f52e8a88121c6d44520824;hb=48b95a9b954b6d9e1b6f98097b35fcca4172c8a0;hp=3e7cf01556e764fd41742e7b5acad336c25db079;hpb=a9baf955fa47b58ec9ae1f90da14abc10379dcde;p=akkoma diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 3e7cf0155..6e5263014 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -17,7 +17,7 @@ defmodule Pleroma.Web.OStatusTest do {:ok, [activity]} = OStatus.handle_incoming(incoming) user = User.get_by_ap_id(activity.data["actor"]) - assert user.info["note_count"] == 1 + assert user.info.note_count == 1 assert activity.data["type"] == "Create" assert activity.data["object"]["type"] == "Note" @@ -278,6 +278,30 @@ defmodule Pleroma.Web.OStatusTest do assert User.following?(follower, followed) end + test "handle incoming unfollows with existing follow" do + incoming_follow = File.read!("test/fixtures/follow.xml") + {:ok, [_activity]} = OStatus.handle_incoming(incoming_follow) + + incoming = File.read!("test/fixtures/unfollow.xml") + {:ok, [activity]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Undo" + + assert activity.data["id"] == + "undo:tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00" + + assert activity.data["actor"] == "https://social.heldscal.la/user/23211" + assert is_map(activity.data["object"]) + assert activity.data["object"]["type"] == "Follow" + assert activity.data["object"]["object"] == "https://pawoo.net/users/pekorino" + refute activity.local + + follower = User.get_by_ap_id(activity.data["actor"]) + followed = User.get_by_ap_id(activity.data["object"]["object"]) + + refute User.following?(follower, followed) + end + describe "new remote user creation" do test "returns local users" do local_user = insert(:user) @@ -295,7 +319,7 @@ defmodule Pleroma.Web.OStatusTest do assert user.name == "Constance Variable" assert user.nickname == "lambadalambda@social.heldscal.la" assert user.local == false - assert user.info["uri"] == uri + assert user.info.uri == uri assert user.ap_id == uri assert user.bio == "Call me Deacon Blues." assert user.avatar["type"] == "Image" @@ -423,7 +447,7 @@ defmodule Pleroma.Web.OStatusTest do end end - test "it doesn't add nil in the do field" do + test "it doesn't add nil in the to field" do incoming = File.read!("test/fixtures/nil_mention_entry.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) @@ -432,4 +456,28 @@ defmodule Pleroma.Web.OStatusTest do "https://www.w3.org/ns/activitystreams#Public" ] end + + describe "is_representable?" do + test "Note objects are representable" do + note_activity = insert(:note_activity) + + assert OStatus.is_representable?(note_activity) + end + + test "Article objects are not representable" do + note_activity = insert(:note_activity) + + note_object = Object.normalize(note_activity.data["object"]) + + note_data = + note_object.data + |> Map.put("type", "Article") + + cs = Object.change(note_object, %{data: note_data}) + {:ok, article_object} = Repo.update(cs) + + # the underlying object is now an Article instead of a note, so this should fail + refute OStatus.is_representable?(note_activity) + end + end end