{: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)
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",
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{
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{
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"
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{
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",
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{
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{
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"
}
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"
}
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"
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{
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"
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"
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"
})
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"
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"
}
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"
} =
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"
})