Allow users to create backups without providing email address
[akkoma] / test / pleroma / web / pleroma_api / controllers / backup_controller_test.exs
index f1941f6ddea7173faa2ad3f8feefa9e597adb641..ba17636daf0905477b82f1fd4233708764fa577a 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
@@ -82,4 +82,24 @@ defmodule Pleroma.Web.PleromaAPI.BackupControllerTest do
              |> post("/api/v1/pleroma/backups")
              |> json_response_and_validate_schema(400)
   end
+
+  test "Backup without email address" do
+    user = Pleroma.Factory.insert(:user, email: nil)
+    %{conn: conn} = oauth_access(["read:accounts"], user: user)
+
+    assert is_nil(user.email)
+
+    assert [
+             %{
+               "content_type" => "application/zip",
+               "url" => _url,
+               "file_size" => 0,
+               "processed" => false,
+               "inserted_at" => _
+             }
+           ] =
+             conn
+             |> post("/api/v1/pleroma/backups")
+             |> json_response_and_validate_schema(:ok)
+  end
 end