alias Pleroma.Web.TwitterAPI.TwitterAPI
alias Pleroma.{Repo, User, Activity}
- alias Pleroma.Web.OStatus
+ alias Pleroma.Web.{OStatus, CommonAPI}
import Pleroma.Factory
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
+
+ describe "user timelines" do
+ test "gets a users statuses", %{conn: conn} do
+ _note = insert(:note_activity)
+ note_two = insert(:note_activity)
+
+ user = User.get_by_ap_id(note_two.data["actor"])
+
+ conn = conn
+ |> get("/api/v1/accounts/#{user.id}/statuses")
+
+ assert [%{"id" => id}] = json_response(conn, 200)
+
+ assert id == note_two.id
+ end
+ end
+
+ describe "user relationships" do
+ test "returns the relationships for the current user", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, user} = User.follow(user, other_user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> get("/api/v1/accounts/relationships", %{"id" => [other_user.id]})
+
+ assert [relationship] = json_response(conn, 200)
+
+ assert other_user.id == relationship["id"]
+ end
+ end
end