fixes after rebase
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 24 Sep 2020 06:42:30 +0000 (09:42 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Thu, 24 Sep 2020 06:42:30 +0000 (09:42 +0300)
lib/pleroma/web/api_spec/operations/pleroma_emoji_file_operation.ex
lib/pleroma/web/router.ex
test/utils_test.exs
test/web/pleroma_api/controllers/emoji_file_controller_test.exs

index efbfce75f57b8e4af96f97c82ff7a172e084b8bc..a56641426961461f0dc4debb2b704c829d169131 100644 (file)
@@ -126,7 +126,7 @@ defmodule Pleroma.Web.ApiSpec.PleromaEmojiFileOperation do
   end
 
   defp name_param do
-    Operation.parameter(:name, :path, :string, "Pack Name", example: "cofe", required: true)
+    Operation.parameter(:name, :query, :string, "Pack Name", example: "cofe", required: true)
   end
 
   defp files_object do
index 707d5e1c4ec552a2c1a7e4e024ed8e17afbea150..e22b31b4c2a47f0b46eb1807c58fd9b24c675059 100644 (file)
@@ -248,13 +248,9 @@ defmodule Pleroma.Web.Router do
       get("/remote", EmojiPackController, :remote)
       post("/download", EmojiPackController, :download)
 
-      post("/create", EmojiPackController, :create)
-      patch("/update", EmojiPackController, :update)
-      delete("/delete", EmojiPackController, :delete)
-
-      post("/files", EmojiFileController, :add_file)
-      patch("/files", EmojiFileController, :update_file)
-      delete("/files", EmojiFileController, :delete_file)
+      post("/files", EmojiFileController, :create)
+      patch("/files", EmojiFileController, :update)
+      delete("/files", EmojiFileController, :delete)
     end
 
     # Pack info / downloading
index 3a730d545fe23288b955e1721e18e05cdcc337e0..460f7e0b5ceb2c9440b5a01c64d18577040770d9 100644 (file)
@@ -8,7 +8,7 @@ defmodule Pleroma.UtilsTest do
   describe "tmp_dir/1" do
     test "returns unique temporary directory" do
       {:ok, path} = Pleroma.Utils.tmp_dir("emoji")
-      assert path =~ ~r/\/tmp\/emoji-(.*)-#{:os.getpid()}-(.*)/
+      assert path =~ ~r/\/emoji-(.*)-#{:os.getpid()}-(.*)/
       File.rm_rf(path)
     end
   end
index 39b4e1dacd376af4c0608ab72784cc71155e4ccd..82de86ee31e4031f3e094a2b9a8f04e57f09aa21 100644 (file)
@@ -29,7 +29,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     {:ok, %{admin_conn: admin_conn}}
   end
 
-  describe "POST/PATCH/DELETE /api/pleroma/emoji/packs/:name/files" do
+  describe "POST/PATCH/DELETE /api/pleroma/emoji/packs/files?name=:name" do
     setup do
       pack_file = "#{@emoji_path}/test_pack/pack.json"
       original_content = File.read!(pack_file)
@@ -56,7 +56,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
       resp =
         admin_conn
         |> put_req_header("content-type", "multipart/form-data")
-        |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+        |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
           file: %Plug.Upload{
             content_type: "application/zip",
             filename: "emojis.zip",
@@ -83,7 +83,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     test "create shortcode exists", %{admin_conn: admin_conn} do
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank",
                filename: "dir/blank.png",
                file: %Plug.Upload{
@@ -101,7 +101,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank3",
                filename: "dir/blank.png",
                file: %Plug.Upload{
@@ -119,7 +119,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank",
                new_shortcode: "blank2",
                new_filename: "dir_2/blank_3.png"
@@ -135,7 +135,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank3",
                filename: "dir/blank.png",
                file: %Plug.Upload{
@@ -153,7 +153,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank3",
                new_shortcode: "blank4",
                new_filename: "dir_2/blank_3.png",
@@ -171,7 +171,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     test "with empty filename", %{admin_conn: admin_conn} do
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank2",
                filename: "",
                file: %Plug.Upload{
@@ -187,7 +187,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     test "add file with not loaded pack", %{admin_conn: admin_conn} do
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/not_loaded/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=not_loaded", %{
                shortcode: "blank3",
                filename: "dir/blank.png",
                file: %Plug.Upload{
@@ -202,7 +202,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
     test "remove file with not loaded pack", %{admin_conn: admin_conn} do
       assert admin_conn
-             |> delete("/api/pleroma/emoji/packs/not_loaded/files?shortcode=blank3")
+             |> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=blank3")
              |> json_response_and_validate_schema(:not_found) == %{
                "error" => "pack \"not_loaded\" is not found"
              }
@@ -210,7 +210,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
     test "remove file with empty shortcode", %{admin_conn: admin_conn} do
       assert admin_conn
-             |> delete("/api/pleroma/emoji/packs/not_loaded/files?shortcode=")
+             |> delete("/api/pleroma/emoji/packs/files?name=not_loaded&shortcode=")
              |> json_response_and_validate_schema(:not_found) == %{
                "error" => "pack \"not_loaded\" is not found"
              }
@@ -219,7 +219,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     test "update file with not loaded pack", %{admin_conn: admin_conn} do
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> patch("/api/pleroma/emoji/packs/not_loaded/files", %{
+             |> patch("/api/pleroma/emoji/packs/files?name=not_loaded", %{
                shortcode: "blank4",
                new_shortcode: "blank3",
                new_filename: "dir_2/blank_3.png"
@@ -232,7 +232,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     test "new with shortcode as file with update", %{admin_conn: admin_conn} do
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank4",
                filename: "dir/blank.png",
                file: %Plug.Upload{
@@ -250,7 +250,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank4",
                new_shortcode: "blank3",
                new_filename: "dir_2/blank_3.png"
@@ -265,7 +265,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
       assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png")
 
       assert admin_conn
-             |> delete("/api/pleroma/emoji/packs/test_pack/files?shortcode=blank3")
+             |> delete("/api/pleroma/emoji/packs/files?name=test_pack&shortcode=blank3")
              |> json_response_and_validate_schema(200) == %{
                "blank" => "blank.png",
                "blank2" => "blank2.png"
@@ -287,7 +287,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank_url",
                file: "https://test-blank/blank_url.png"
              })
@@ -307,7 +307,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> post("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> post("/api/pleroma/emoji/packs/files?name=test_pack", %{
                file: %Plug.Upload{
                  filename: "shortcode.png",
                  path: "#{Pleroma.Config.get([:instance, :static_dir])}/add/shortcode.png"
@@ -322,7 +322,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
 
     test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
       assert admin_conn
-             |> delete("/api/pleroma/emoji/packs/test_pack/files?shortcode=blank3")
+             |> delete("/api/pleroma/emoji/packs/files?name=test_pack&shortcode=blank3")
              |> json_response_and_validate_schema(:bad_request) == %{
                "error" => "Emoji \"blank3\" does not exist"
              }
@@ -331,7 +331,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
     test "update non existing emoji", %{admin_conn: admin_conn} do
       assert admin_conn
              |> put_req_header("content-type", "multipart/form-data")
-             |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
+             |> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
                shortcode: "blank3",
                new_shortcode: "blank4",
                new_filename: "dir_2/blank_3.png"
@@ -347,7 +347,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
              } =
                admin_conn
                |> put_req_header("content-type", "multipart/form-data")
-               |> patch("/api/pleroma/emoji/packs/test_pack/files", %{
+               |> patch("/api/pleroma/emoji/packs/files?name=test_pack", %{
                  shortcode: "blank",
                  new_filename: "dir_2/blank_3.png"
                })