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)
end
end
+ describe "GET /api/statuses/friends" do
+ test "it returns a user's friends", %{conn: conn} do
+ user = insert(:user)
+ followed_one = insert(:user)
+ followed_two = insert(:user)
+ not_followed = insert(:user)
+
+ {:ok, user} = User.follow(user, followed_one)
+ {:ok, user} = User.follow(user, followed_two)
+
+ conn = conn
+ |> assign(:user, user)
+ |> get("/api/statuses/friends")
+
+ assert json_response(conn, 200) == UserView.render("index.json", %{users: [followed_one, followed_two], for: user})
+ end
+ end
+
+ describe "POST /api/account/update_profile.json" do
+ test "it updates a user's profile" do
+ user = insert(:user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> post("/api/account/update_profile.json", %{"name" => "new name", "description" => "new description"})
+
+ user = Repo.get!(User, user.id)
+ assert user.name == "new name"
+ assert user.bio == "new description"
+
+ assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
+ end
+ end
+
defp valid_user(_context) do
user = insert(:user)
[user: user]