From 5b0d0b9ab2e9efba3d170a06ea3cc5c4ca33c2c9 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Sat, 14 Apr 2018 22:34:06 -0400 Subject: [PATCH] Add unreblogging tests --- test/web/activity_pub/activity_pub_test.exs | 20 +++++++++++++++++++ .../mastodon_api_controller_test.exs | 19 ++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 657d75a55..84f844322 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -271,6 +271,26 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end end + describe "unannouncing an object" do + test "unannouncing a previously announced object" do + note_activity = insert(:note_activity) + object = Object.get_by_ap_id(note_activity.data["object"]["id"]) + user = insert(:user) + + # Unannouncing an object that is not announced does nothing + {:ok, object} = ActivityPub.unannounce(user, object) + assert object.data["announcement_count"] == 0 + + {:ok, announce_activity, object} = ActivityPub.announce(user, object) + assert object.data["announcement_count"] == 1 + + {:ok, object} = ActivityPub.unannounce(user, object) + assert object.data["announcement_count"] == 0 + + assert Repo.get(Activity, announce_activity.id) == nil + end + end + describe "uploading files" do test "copies the file to the configured folder" do file = %Plug.Upload{ diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 5293b9364..f3a9c1def 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -264,6 +264,25 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do end end + describe "unreblogging" do + test "unreblogs and returns the unreblogged status", %{conn: conn} do + activity = insert(:note_activity) + user = insert(:user) + + {:ok, _, _} = CommonAPI.repeat(activity.id, user) + + conn = + conn + |> assign(:user, user) + |> post("/api/v1/statuses/#{activity.id}/unreblog") + + assert %{"reblog" => %{"id" => id, "reblogged" => false, "reblogs_count" => 0}} = + json_response(conn, 200) + + assert to_string(activity.id) == id + end + end + describe "favoriting" do test "favs a status and returns it", %{conn: conn} do activity = insert(:note_activity) -- 2.45.2