1 defmodule Pleroma.UploadTest do
5 describe "Storing a file" do
6 test "copies the file to the configured folder with deduping" do
7 File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
10 content_type: "image/jpg",
11 path: Path.absname("test/fixtures/image_tmp.jpg"),
12 filename: "an [image.jpg"
15 data = Upload.store(file, true)
17 assert data["name"] ==
18 "e7a6d0cf595bff76f14c9a98b6c199539559e8b844e02e51e5efcfd1f614a2df.jpeg"
21 test "copies the file to the configured folder without deduping" do
22 File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
25 content_type: "image/jpg",
26 path: Path.absname("test/fixtures/image_tmp.jpg"),
27 filename: "an [image.jpg"
30 data = Upload.store(file, false)
31 assert data["name"] == "an [image.jpg"
34 test "fixes incorrect content type" do
35 File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
38 content_type: "application/octet-stream",
39 path: Path.absname("test/fixtures/image_tmp.jpg"),
40 filename: "an [image.jpg"
43 data = Upload.store(file, true)
44 assert hd(data["url"])["mediaType"] == "image/jpeg"
47 test "adds missing extension" do
48 File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
51 content_type: "image/jpg",
52 path: Path.absname("test/fixtures/image_tmp.jpg"),
56 data = Upload.store(file, false)
57 assert data["name"] == "an [image.jpg"