X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fupload_test.exs;h=b2ce755d2b44fa42ec2f6cf33ab1aa55f410966f;hb=80bfdb4e7d3e339a1e47330c0de0fe7af9c00ab1;hp=65562cb2a0d27fce879e5f239c3a53dfb5591b88;hpb=02d3dc6869f388388ea744ea4ee3b54279d55e86;p=akkoma diff --git a/test/upload_test.exs b/test/upload_test.exs index 65562cb2a..b2ce755d2 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -20,8 +20,6 @@ defmodule Pleroma.UploadTest do :ok end - OH - HELLO - EAL - test "returns a media url" do File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") @@ -38,6 +36,24 @@ defmodule Pleroma.UploadTest do assert String.starts_with?(url, Pleroma.Web.base_url() <> "/media/") end + test "returns a media url with configured base_url" do + base_url = "https://cache.pleroma.social" + + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + + file = %Plug.Upload{ + content_type: "image/jpg", + path: Path.absname("test/fixtures/image_tmp.jpg"), + filename: "image.jpg" + } + + {:ok, data} = Upload.store(file, base_url: base_url) + + assert %{"url" => [%{"href" => url}]} = data + + assert String.starts_with?(url, base_url <> "/media/") + end + test "copies the file to the configured folder with deduping" do File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") @@ -118,5 +134,19 @@ defmodule Pleroma.UploadTest do {:ok, data} = Upload.store(file) assert data["name"] == "test.txt" end + + test "copies the file to the configured folder with anonymizing filename" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + + file = %Plug.Upload{ + content_type: "image/jpg", + path: Path.absname("test/fixtures/image_tmp.jpg"), + filename: "an [image.jpg" + } + + {:ok, data} = Upload.store(file, filters: [Pleroma.Upload.Filter.AnonymizeFilename]) + + refute data["name"] == "an [image.jpg" + end end end