Add reblogging to MastodonAPI.

This commit is contained in:
Roger Braun 2017-09-09 17:48:57 +02:00
commit 66e4c710d4
9 changed files with 58 additions and 33 deletions

View file

@ -121,4 +121,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert Repo.get(Activity, activity.id) == activity
end
end
describe "reblogging" do
test "reblogs and returns the reblogged status", %{conn: conn} do
activity = insert(:note_activity)
user = insert(:user)
conn = conn
|> assign(:user, user)
|> post("/api/v1/statuses/#{activity.id}/reblog")
assert %{"id" => id, "reblogged" => true, "reblogs_count" => 1} = json_response(conn, 200)
assert activity.id == id
end
end
end

View file

@ -354,13 +354,6 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
request_path = "/api/statuses/retweet/#{note_activity.id}.json"
user = Repo.get_by(User, ap_id: note_activity.data["actor"])
response = conn
|> with_credentials(user.nickname, "test")
|> post(request_path)
assert json_response(response, 400) == %{"error" => "You cannot repeat your own notice.",
"request" => request_path}
response = conn
|> with_credentials(current_user.nickname, "test")
|> post(request_path)

View file

@ -290,7 +290,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
note_activity = insert(:note_activity)
activity_user = Repo.get_by!(User, ap_id: note_activity.data["actor"])
{:ok, status} = TwitterAPI.retweet(user, note_activity)
{:ok, status} = TwitterAPI.repeat(user, note_activity.id)
updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
assert status == ActivityRepresenter.to_map(updated_activity, %{user: activity_user, for: user})