1 defmodule Pleroma.UploadTest do
5 describe "Storing a file" do
6 test "copies the file to the configured folder" do
8 content_type: "image/jpg",
9 path: Path.absname("test/fixtures/image.jpg"),
10 filename: "an [image.jpg"
13 data = Upload.store(file)
14 assert data["name"] == "an [image.jpg"
16 assert List.first(data["url"])["href"] ==
17 "http://localhost:4001/media/#{data["uuid"]}/an%20%5Bimage.jpg"
20 test "fixes an incorrect content type" do
22 content_type: "application/octet-stream",
23 path: Path.absname("test/fixtures/image.jpg"),
24 filename: "an [image.jpg"
27 data = Upload.store(file)
28 assert hd(data["url"])["mediaType"] == "image/jpeg"
31 test "does not modify a valid content type" do
33 content_type: "image/png",
34 path: Path.absname("test/fixtures/image.jpg"),
35 filename: "an [image.jpg"
38 data = Upload.store(file)
39 assert hd(data["url"])["mediaType"] == "image/png"