Allow importing old (emoji.txt / plain) packs from the filesystem
This commit is contained in:
parent
13cd93a0d3
commit
9eb2ee4df0
4 changed files with 109 additions and 0 deletions
BIN
test/instance_static/emoji/test_pack_for_import/blank.png
Normal file
BIN
test/instance_static/emoji/test_pack_for_import/blank.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 B |
|
|
@ -365,4 +365,45 @@ defmodule Pleroma.Web.EmojiAPI.EmojiAPIControllerTest do
|
|||
|
||||
refute File.exists?("#{@emoji_dir_path}/test_created/pack.json")
|
||||
end
|
||||
|
||||
test "filesystem import" do
|
||||
on_exit(fn ->
|
||||
File.rm!("#{@emoji_dir_path}/test_pack_for_import/emoji.txt")
|
||||
File.rm!("#{@emoji_dir_path}/test_pack_for_import/pack.json")
|
||||
end)
|
||||
|
||||
conn = build_conn()
|
||||
resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
|
||||
|
||||
refute Map.has_key?(resp, "test_pack_for_import")
|
||||
|
||||
admin = insert(:user, info: %{is_admin: true})
|
||||
|
||||
assert conn
|
||||
|> assign(:user, admin)
|
||||
|> post(emoji_api_path(conn, :import_from_fs))
|
||||
|> json_response(200) == ["test_pack_for_import"]
|
||||
|
||||
resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
|
||||
assert resp["test_pack_for_import"]["files"] == %{"blank" => "blank.png"}
|
||||
|
||||
File.rm!("#{@emoji_dir_path}/test_pack_for_import/pack.json")
|
||||
refute File.exists?("#{@emoji_dir_path}/test_pack_for_import/pack.json")
|
||||
|
||||
emoji_txt_content = "blank, blank.png, Fun\n\nblank2, blank.png"
|
||||
|
||||
File.write!("#{@emoji_dir_path}/test_pack_for_import/emoji.txt", emoji_txt_content)
|
||||
|
||||
assert conn
|
||||
|> assign(:user, admin)
|
||||
|> post(emoji_api_path(conn, :import_from_fs))
|
||||
|> json_response(200) == ["test_pack_for_import"]
|
||||
|
||||
resp = conn |> get(emoji_api_path(conn, :list_packs)) |> json_response(200)
|
||||
|
||||
assert resp["test_pack_for_import"]["files"] == %{
|
||||
"blank" => "blank.png",
|
||||
"blank2" => "blank.png"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue