diff options
author | lain <lain@soykaf.club> | 2019-10-02 15:08:20 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-10-02 15:08:20 +0200 |
commit | dfe5c958eb94326f5a7743c9de0de073260db926 (patch) | |
tree | 2b157f99f4d64430130f94de5017d8adccc2e65a /test | |
parent | 557223b2b5b60956d3e1a19e9fdae9e9798c4fe2 (diff) | |
download | pleroma-dfe5c958eb94326f5a7743c9de0de073260db926.tar.gz pleroma-dfe5c958eb94326f5a7743c9de0de073260db926.zip |
ActivityPub: Add undo for emoji reactions.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 8c9c2c89e..36a82d6a1 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -761,16 +761,40 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end describe "unreacting to an object" do - test "adds an emoji reaction activity to the db" do + test_with_mock "sends an activity to federation", Pleroma.Web.Federator, [:passthrough], [] do + Pleroma.Config.put([:instance, :federating], true) user = insert(:user) reactor = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) assert object = Object.normalize(activity) - {:ok, reaction_activity, object} = ActivityPub.react_with_emoji(reactor, object, "🔥") - {:ok, unreaction_activity} = ActivityPub.unreact_with_emoji(reactor, reaction_activity.id) + {:ok, reaction_activity, _object} = ActivityPub.react_with_emoji(reactor, object, "🔥") + + assert called(Pleroma.Web.Federator.publish(reaction_activity)) + + {:ok, unreaction_activity, _object} = + ActivityPub.unreact_with_emoji(reactor, reaction_activity.data["id"]) + + assert called(Pleroma.Web.Federator.publish(unreaction_activity)) + end + + test "adds an undo activity to the db" do + user = insert(:user) + reactor = insert(:user) + {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"}) + assert object = Object.normalize(activity) + + {:ok, reaction_activity, _object} = ActivityPub.react_with_emoji(reactor, object, "🔥") + + {:ok, unreaction_activity, _object} = + ActivityPub.unreact_with_emoji(reactor, reaction_activity.data["id"]) + + assert unreaction_activity.actor == reactor.ap_id + assert unreaction_activity.data["object"] == reaction_activity.data["id"] - IO.inspect(object) + object = Object.get_by_ap_id(object.data["id"]) + assert object.data["reaction_count"] == 0 + assert object.data["reactions"] == %{} end end |