aboutsummaryrefslogtreecommitdiff
path: root/test/web/twitter_api/twitter_api_controller_test.exs
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-03-23 13:13:09 +0100
committerRoger Braun <roger@rogerbraun.net>2017-03-23 13:13:09 +0100
commit30650e5bc610810d129bf02891a73ac11340710b (patch)
tree961bc760faea353f875f32325acd0cc296ce16ad /test/web/twitter_api/twitter_api_controller_test.exs
parent75e51b190d5b4bd4e9cbf6a669bfce7a440e1a5c (diff)
downloadpleroma-30650e5bc610810d129bf02891a73ac11340710b.tar.gz
Add unfollowing to TwAPI.
Diffstat (limited to 'test/web/twitter_api/twitter_api_controller_test.exs')
-rw-r--r--test/web/twitter_api/twitter_api_controller_test.exs23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs
index a504393be..b0a0cdb54 100644
--- a/test/web/twitter_api/twitter_api_controller_test.exs
+++ b/test/web/twitter_api/twitter_api_controller_test.exs
@@ -99,6 +99,29 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
end
end
+ describe "POST /friendships/destroy.json" do
+ setup [:valid_user]
+ test "without valid credentials", %{conn: conn} do
+ conn = post conn, "/api/friendships/destroy.json"
+ assert json_response(conn, 403) == %{"error" => "Invalid credentials."}
+ end
+
+ test "with credentials", %{conn: conn, user: current_user} do
+ {:ok, followed } = UserBuilder.insert(%{name: "some guy"})
+
+ {:ok, current_user} = User.follow(current_user, followed)
+ assert current_user.following == [User.ap_followers(followed)]
+
+ conn = conn
+ |> with_credentials(current_user.nickname, "test")
+ |> post("/api/friendships/destroy.json", %{user_id: followed.id})
+
+ current_user = Repo.get(User, current_user.id)
+ assert current_user.following == []
+ assert json_response(conn, 200) == UserRepresenter.to_map(followed)
+ end
+ end
+
defp valid_user(_context) do
{ :ok, user } = UserBuilder.insert(%{nickname: "lambda", ap_id: "lambda"})
[user: user]