diff options
author | kaniini <nenolod@gmail.com> | 2018-12-27 19:37:55 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2018-12-27 19:37:55 +0000 |
commit | bee6acd51dc4e84e44caecf9d123dfff2f640a38 (patch) | |
tree | 2436614e22c005e7417cd863301f8b27fd919704 /test | |
parent | cff0292d4b32cf51de8ad15281c35d783b137dd2 (diff) | |
parent | 012b7ab5e64eae468c630730f392ea8289a5d874 (diff) | |
download | pleroma-bee6acd51dc4e84e44caecf9d123dfff2f640a38.tar.gz |
Merge branch 'feature/create-tombstone-instead-of-delete' into 'develop'
Create tombstone instead of object deletion
See merge request pleroma/pleroma!593
Diffstat (limited to 'test')
-rw-r--r-- | test/activity_test.exs | 8 | ||||
-rw-r--r-- | test/object_test.exs | 4 | ||||
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 2 | ||||
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 2 | ||||
-rw-r--r-- | test/web/ostatus/incoming_documents/delete_handling_test.exs | 2 | ||||
-rw-r--r-- | test/web/ostatus/ostatus_controller_test.exs | 18 |
6 files changed, 28 insertions, 8 deletions
diff --git a/test/activity_test.exs b/test/activity_test.exs index cf27fbbc5..36c718869 100644 --- a/test/activity_test.exs +++ b/test/activity_test.exs @@ -4,18 +4,19 @@ defmodule Pleroma.ActivityTest do use Pleroma.DataCase + alias Pleroma.Activity import Pleroma.Factory test "returns an activity by it's AP id" do activity = insert(:note_activity) - found_activity = Pleroma.Activity.get_by_ap_id(activity.data["id"]) + found_activity = Activity.get_by_ap_id(activity.data["id"]) assert activity == found_activity end test "returns activities by it's objects AP ids" do activity = insert(:note_activity) - [found_activity] = Pleroma.Activity.all_by_object_ap_id(activity.data["object"]["id"]) + [found_activity] = Activity.all_by_object_ap_id(activity.data["object"]["id"]) assert activity == found_activity end @@ -23,8 +24,7 @@ defmodule Pleroma.ActivityTest do test "returns the activity that created an object" do activity = insert(:note_activity) - found_activity = - Pleroma.Activity.get_create_activity_by_object_ap_id(activity.data["object"]["id"]) + found_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"]["id"]) assert activity == found_activity end diff --git a/test/object_test.exs b/test/object_test.exs index 0effb9505..72194975d 100644 --- a/test/object_test.exs +++ b/test/object_test.exs @@ -36,6 +36,8 @@ defmodule Pleroma.ObjectTest do found_object = Object.get_by_ap_id(object.data["id"]) refute object == found_object + + assert found_object.data["type"] == "Tombstone" end test "ensures cache is cleared for the object" do @@ -51,6 +53,8 @@ defmodule Pleroma.ObjectTest do cached_object = Object.get_cached_by_ap_id(object.data["id"]) refute object == cached_object + + assert cached_object.data["type"] == "Tombstone" end end end diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index f7c66038d..7bccd7500 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -492,7 +492,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do assert Repo.get(Activity, delete.id) != nil - assert Repo.get(Object, object.id) == nil + assert Repo.get(Object, object.id).data["type"] == "Tombstone" end end diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 1737a5ebe..0136acf8c 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -296,7 +296,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert %{} = json_response(conn, 200) - assert Repo.get(Activity, activity.id) == nil + refute Repo.get(Activity, activity.id) end test "when you didn't create it", %{conn: conn} do diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs index 1e041e5b0..c8fbff6cc 100644 --- a/test/web/ostatus/incoming_documents/delete_handling_test.exs +++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs @@ -25,7 +25,7 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do refute Repo.get(Activity, note.id) refute Repo.get(Activity, like.id) - refute Object.get_by_ap_id(note.data["object"]["id"]) + assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone" assert Repo.get(Activity, second_note.id) assert Object.get_by_ap_id(second_note.data["object"]["id"]) diff --git a/test/web/ostatus/ostatus_controller_test.exs b/test/web/ostatus/ostatus_controller_test.exs index 6b535a1a9..995cc00d6 100644 --- a/test/web/ostatus/ostatus_controller_test.exs +++ b/test/web/ostatus/ostatus_controller_test.exs @@ -5,7 +5,7 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do use Pleroma.Web.ConnCase import Pleroma.Factory - alias Pleroma.{User, Repo} + alias Pleroma.{User, Repo, Object} alias Pleroma.Web.CommonAPI alias Pleroma.Web.OStatus.ActivityRepresenter @@ -114,6 +114,22 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do |> response(404) end + test "404s on deleted objects", %{conn: conn} do + note_activity = insert(:note_activity) + [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])) + object = Object.get_by_ap_id(note_activity.data["object"]["id"]) + + conn + |> get("/objects/#{uuid}") + |> response(200) + + Object.delete(object) + + conn + |> get("/objects/#{uuid}") + |> response(404) + end + test "gets an activity", %{conn: conn} do note_activity = insert(:note_activity) [_, uuid] = hd(Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])) |