summaryrefslogtreecommitdiff
path: root/test/web/emoji_api_controller_test.exs
diff options
context:
space:
mode:
authorEkaterina Vaartis <vaartis@cock.li>2019-08-20 14:52:36 +0300
committerEkaterina Vaartis <vaartis@cock.li>2019-09-19 00:16:33 +0300
commit8dbdd5c280d15fde4712989001d4ddee1cd37cff (patch)
tree5c9a4b4e5a65ddc657a909d8956dbdba08d89be6 /test/web/emoji_api_controller_test.exs
parent16edfef12e6781971e2056a80a0ac38dcc254b1b (diff)
downloadpleroma-8dbdd5c280d15fde4712989001d4ddee1cd37cff.tar.gz
pleroma-8dbdd5c280d15fde4712989001d4ddee1cd37cff.zip
Allow uploading new emojis to packs from URLs
Diffstat (limited to 'test/web/emoji_api_controller_test.exs')
-rw-r--r--test/web/emoji_api_controller_test.exs34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/web/emoji_api_controller_test.exs b/test/web/emoji_api_controller_test.exs
index 6d3603da5..c1aece691 100644
--- a/test/web/emoji_api_controller_test.exs
+++ b/test/web/emoji_api_controller_test.exs
@@ -244,6 +244,7 @@ defmodule Pleroma.Web.EmojiAPI.EmojiAPIControllerTest do
on_exit(fn ->
File.write!(pack_file, original_content)
+ File.rm_rf!("#{@emoji_dir_path}/test_pack/blank_url.png")
File.rm_rf!("#{@emoji_dir_path}/test_pack/dir")
File.rm_rf!("#{@emoji_dir_path}/test_pack/dir_2")
end)
@@ -296,5 +297,38 @@ defmodule Pleroma.Web.EmojiAPI.EmojiAPIControllerTest do
|> json_response(200) == %{"blank" => "blank.png"}
refute File.exists?("#{@emoji_dir_path}/test_pack/dir_2/")
+
+ mock(fn
+ %{
+ method: :get,
+ url: "https://test-blank/blank_url.png"
+ } ->
+ text(File.read!("#{@emoji_dir_path}/test_pack/blank.png"))
+ end)
+
+ # The name should be inferred from the URL ending
+ from_url = %{
+ "action" => "add",
+ "shortcode" => "blank_url",
+ "file" => "https://test-blank/blank_url.png"
+ }
+
+ assert conn
+ |> post(emoji_api_path(conn, :update_file, "test_pack"), from_url)
+ |> json_response(200) == %{
+ "blank" => "blank.png",
+ "blank_url" => "blank_url.png"
+ }
+
+ assert File.exists?("#{@emoji_dir_path}/test_pack/blank_url.png")
+
+ assert conn
+ |> post(emoji_api_path(conn, :update_file, "test_pack"), %{
+ "action" => "remove",
+ "shortcode" => "blank_url"
+ })
+ |> json_response(200) == %{"blank" => "blank.png"}
+
+ refute File.exists?("#{@emoji_dir_path}/test_pack/blank_url.png")
end
end