Add unfav to Mastodon API.
This commit is contained in:
parent
454dc18570
commit
d625d8db7d
7 changed files with 49 additions and 22 deletions
|
|
@ -3,7 +3,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
alias Pleroma.Web.TwitterAPI.TwitterAPI
|
||||
alias Pleroma.{Repo, User, Activity}
|
||||
alias Pleroma.Web.OStatus
|
||||
alias Pleroma.Web.{OStatus, CommonAPI}
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
|
|
@ -149,4 +149,20 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert activity.id == id
|
||||
end
|
||||
end
|
||||
|
||||
describe "unfavoriting" do
|
||||
test "unfavorites a status and returns it", %{conn: conn} do
|
||||
activity = insert(:note_activity)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, _, _} = CommonAPI.favorite(activity.id, user)
|
||||
|
||||
conn = conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/statuses/#{activity.id}/unfavourite")
|
||||
|
||||
assert %{"id" => id, "favourites_count" => 0, "favourited" => false} = json_response(conn, 200)
|
||||
assert activity.id == id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
|
||||
assert ActivityRepresenter.to_map(updated_activity, %{user: activity_user, for: user})["fave_num"] == 1
|
||||
|
||||
{:ok, status} = TwitterAPI.unfavorite(user, note_activity)
|
||||
{:ok, status} = TwitterAPI.unfav(user, note_activity.id)
|
||||
|
||||
assert status["fave_num"] == 0
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue