fixes after rebase

This commit is contained in:
Alexander Strizhakov 2020-09-24 09:42:30 +03:00
parent 871fac3e4c
commit 5d7ec00bed
No known key found for this signature in database
GPG Key ID: 022896A53AEF1381
4 changed files with 25 additions and 29 deletions

View File

@ -126,7 +126,7 @@ def delete_operation do
end end
defp name_param do 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 end
defp files_object do defp files_object do

View File

@ -248,13 +248,9 @@ defmodule Pleroma.Web.Router do
get("/remote", EmojiPackController, :remote) get("/remote", EmojiPackController, :remote)
post("/download", EmojiPackController, :download) post("/download", EmojiPackController, :download)
post("/create", EmojiPackController, :create) post("/files", EmojiFileController, :create)
patch("/update", EmojiPackController, :update) patch("/files", EmojiFileController, :update)
delete("/delete", EmojiPackController, :delete) delete("/files", EmojiFileController, :delete)
post("/files", EmojiFileController, :add_file)
patch("/files", EmojiFileController, :update_file)
delete("/files", EmojiFileController, :delete_file)
end end
# Pack info / downloading # Pack info / downloading

View File

@ -8,7 +8,7 @@ defmodule Pleroma.UtilsTest do
describe "tmp_dir/1" do describe "tmp_dir/1" do
test "returns unique temporary directory" do test "returns unique temporary directory" do
{:ok, path} = Pleroma.Utils.tmp_dir("emoji") {:ok, path} = Pleroma.Utils.tmp_dir("emoji")
assert path =~ ~r/\/tmp\/emoji-(.*)-#{:os.getpid()}-(.*)/ assert path =~ ~r/\/emoji-(.*)-#{:os.getpid()}-(.*)/
File.rm_rf(path) File.rm_rf(path)
end end
end end

View File

@ -29,7 +29,7 @@ defmodule Pleroma.Web.PleromaAPI.EmojiFileControllerTest do
{:ok, %{admin_conn: admin_conn}} {:ok, %{admin_conn: admin_conn}}
end 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 setup do
pack_file = "#{@emoji_path}/test_pack/pack.json" pack_file = "#{@emoji_path}/test_pack/pack.json"
original_content = File.read!(pack_file) original_content = File.read!(pack_file)
@ -56,7 +56,7 @@ test "upload zip file with emojies", %{admin_conn: admin_conn} do
resp = resp =
admin_conn admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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{ file: %Plug.Upload{
content_type: "application/zip", content_type: "application/zip",
filename: "emojis.zip", filename: "emojis.zip",
@ -83,7 +83,7 @@ test "upload zip file with emojies", %{admin_conn: admin_conn} do
test "create shortcode exists", %{admin_conn: admin_conn} do test "create shortcode exists", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank",
filename: "dir/blank.png", filename: "dir/blank.png",
file: %Plug.Upload{ file: %Plug.Upload{
@ -101,7 +101,7 @@ test "don't rewrite old emoji", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank3",
filename: "dir/blank.png", filename: "dir/blank.png",
file: %Plug.Upload{ file: %Plug.Upload{
@ -119,7 +119,7 @@ test "don't rewrite old emoji", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank",
new_shortcode: "blank2", new_shortcode: "blank2",
new_filename: "dir_2/blank_3.png" new_filename: "dir_2/blank_3.png"
@ -135,7 +135,7 @@ test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank3",
filename: "dir/blank.png", filename: "dir/blank.png",
file: %Plug.Upload{ file: %Plug.Upload{
@ -153,7 +153,7 @@ test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank3",
new_shortcode: "blank4", new_shortcode: "blank4",
new_filename: "dir_2/blank_3.png", new_filename: "dir_2/blank_3.png",
@ -171,7 +171,7 @@ test "rewrite old emoji with force option", %{admin_conn: admin_conn} do
test "with empty filename", %{admin_conn: admin_conn} do test "with empty filename", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank2",
filename: "", filename: "",
file: %Plug.Upload{ file: %Plug.Upload{
@ -187,7 +187,7 @@ test "with empty filename", %{admin_conn: admin_conn} do
test "add file with not loaded pack", %{admin_conn: admin_conn} do test "add file with not loaded pack", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank3",
filename: "dir/blank.png", filename: "dir/blank.png",
file: %Plug.Upload{ file: %Plug.Upload{
@ -202,7 +202,7 @@ test "add file with not loaded pack", %{admin_conn: admin_conn} do
test "remove file with not loaded pack", %{admin_conn: admin_conn} do test "remove file with not loaded pack", %{admin_conn: admin_conn} do
assert admin_conn 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) == %{ |> json_response_and_validate_schema(:not_found) == %{
"error" => "pack \"not_loaded\" is not found" "error" => "pack \"not_loaded\" is not found"
} }
@ -210,7 +210,7 @@ test "remove file with not loaded pack", %{admin_conn: admin_conn} do
test "remove file with empty shortcode", %{admin_conn: admin_conn} do test "remove file with empty shortcode", %{admin_conn: admin_conn} do
assert admin_conn 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) == %{ |> json_response_and_validate_schema(:not_found) == %{
"error" => "pack \"not_loaded\" is not found" "error" => "pack \"not_loaded\" is not found"
} }
@ -219,7 +219,7 @@ test "remove file with empty shortcode", %{admin_conn: admin_conn} do
test "update file with not loaded pack", %{admin_conn: admin_conn} do test "update file with not loaded pack", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank4",
new_shortcode: "blank3", new_shortcode: "blank3",
new_filename: "dir_2/blank_3.png" new_filename: "dir_2/blank_3.png"
@ -232,7 +232,7 @@ test "update file with not loaded pack", %{admin_conn: admin_conn} do
test "new with shortcode as file with update", %{admin_conn: admin_conn} do test "new with shortcode as file with update", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank4",
filename: "dir/blank.png", filename: "dir/blank.png",
file: %Plug.Upload{ file: %Plug.Upload{
@ -250,7 +250,7 @@ test "new with shortcode as file with update", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank4",
new_shortcode: "blank3", new_shortcode: "blank3",
new_filename: "dir_2/blank_3.png" new_filename: "dir_2/blank_3.png"
@ -265,7 +265,7 @@ test "new with shortcode as file with update", %{admin_conn: admin_conn} do
assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png") assert File.exists?("#{@emoji_path}/test_pack/dir_2/blank_3.png")
assert admin_conn 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) == %{ |> json_response_and_validate_schema(200) == %{
"blank" => "blank.png", "blank" => "blank.png",
"blank2" => "blank2.png" "blank2" => "blank2.png"
@ -287,7 +287,7 @@ test "new with shortcode from url", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank_url",
file: "https://test-blank/blank_url.png" file: "https://test-blank/blank_url.png"
}) })
@ -307,7 +307,7 @@ test "new without shortcode", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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{ file: %Plug.Upload{
filename: "shortcode.png", filename: "shortcode.png",
path: "#{Pleroma.Config.get([:instance, :static_dir])}/add/shortcode.png" path: "#{Pleroma.Config.get([:instance, :static_dir])}/add/shortcode.png"
@ -322,7 +322,7 @@ test "new without shortcode", %{admin_conn: admin_conn} do
test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
assert admin_conn 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) == %{ |> json_response_and_validate_schema(:bad_request) == %{
"error" => "Emoji \"blank3\" does not exist" "error" => "Emoji \"blank3\" does not exist"
} }
@ -331,7 +331,7 @@ test "remove non existing shortcode in pack.json", %{admin_conn: admin_conn} do
test "update non existing emoji", %{admin_conn: admin_conn} do test "update non existing emoji", %{admin_conn: admin_conn} do
assert admin_conn assert admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank3",
new_shortcode: "blank4", new_shortcode: "blank4",
new_filename: "dir_2/blank_3.png" new_filename: "dir_2/blank_3.png"
@ -347,7 +347,7 @@ test "update with empty shortcode", %{admin_conn: admin_conn} do
} = } =
admin_conn admin_conn
|> put_req_header("content-type", "multipart/form-data") |> 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", shortcode: "blank",
new_filename: "dir_2/blank_3.png" new_filename: "dir_2/blank_3.png"
}) })