X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fupload_test.exs;h=b06b54487e152dc397e3127930e481cefbaedace;hb=b36b6259d8fcd677cfe3c5dc97d25bdc45c226f5;hp=95b16078bb0458de4c4692e79e33eb985d1b7fff;hpb=84fca14c3c6b3a5a6f3b0894903867dfa50a78bb;p=akkoma diff --git a/test/upload_test.exs b/test/upload_test.exs index 95b16078b..b06b54487 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2018 Pleroma Authors +# Copyright © 2017-2020 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.UploadTest do @@ -54,6 +54,7 @@ defmodule Pleroma.UploadTest do %{ "name" => "image.jpg", "type" => "Document", + "mediaType" => "image/jpeg", "url" => [ %{ "href" => "http://localhost:4001/media/post-process-file.jpg", @@ -106,6 +107,19 @@ defmodule Pleroma.UploadTest do describe "Storing a file with the Local uploader" do setup [:ensure_local_uploader] + test "does not allow descriptions longer than the post limit" do + clear_config([:instance, :description_limit], 2) + 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" + } + + {:error, :description_too_long} = Upload.store(file, description: "123") + end + test "returns a media url" do File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") @@ -250,13 +264,7 @@ defmodule Pleroma.UploadTest do end describe "Setting a custom base_url for uploaded media" do - setup do - Pleroma.Config.put([Pleroma.Upload, :base_url], "https://cache.pleroma.social") - - on_exit(fn -> - Pleroma.Config.put([Pleroma.Upload, :base_url], nil) - end) - end + setup do: clear_config([Pleroma.Upload, :base_url], "https://cache.pleroma.social") test "returns a media url with configured base_url" do base_url = Pleroma.Config.get([Pleroma.Upload, :base_url])