+
+ assert Enum.at(response, 0) ==
+ ActivityRepresenter.to_map(activity, %{
+ user: current_user,
+ mentioned: [current_user]
+ })
+ end
+ end
+
+ describe "GET /api/qvitter/statuses/notifications.json" do
+ setup [:valid_user]
+
+ test "without valid credentials", %{conn: conn} do
+ conn = get(conn, "/api/qvitter/statuses/notifications.json")
+ assert json_response(conn, 403) == %{"error" => "Invalid credentials."}
+ end
+
+ test "with credentials", %{conn: conn, user: current_user} do
+ other_user = insert(:user)
+
+ {:ok, activity} =
+ ActivityBuilder.insert(%{"to" => [current_user.ap_id]}, %{user: other_user})
+
+ conn =
+ conn
+ |> with_credentials(current_user.nickname, "test")
+ |> get("/api/qvitter/statuses/notifications.json")
+
+ response = json_response(conn, 200)
+
+ assert length(response) == 1
+
+ assert response ==
+ NotificationView.render("notification.json", %{
+ notifications: Notification.for_user(current_user),
+ for: current_user
+ })