diff options
author | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-08-18 19:02:33 +0000 |
---|---|---|
committer | Haelwenn <contact+git.pleroma.social@hacktivis.me> | 2020-08-18 19:02:33 +0000 |
commit | 3d5d8c05c9de9a70a8d49576f125b9987f9d34e8 (patch) | |
tree | 44de972a82f2593b9d34378ddecb2acaf229be08 /test | |
parent | fa8a87eca1892b094e5faafc48404dd1a75e4a57 (diff) | |
parent | 52a79506c786a1388eeab24892c7b36ee9682977 (diff) | |
download | pleroma-3d5d8c05c9de9a70a8d49576f125b9987f9d34e8.tar.gz |
Merge branch '2064-image-blanking' into 'develop'
Resolve "Make default image description blank"
Closes #2064
See merge request pleroma/pleroma!2899
Diffstat (limited to 'test')
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index d6eab7337..03f968aaf 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -990,13 +990,39 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end describe "uploading files" do - test "copies the file to the configured folder" do - file = %Plug.Upload{ + setup do + test_file = %Plug.Upload{ content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an_image.jpg" } + %{test_file: test_file} + end + + test "sets a description if given", %{test_file: file} do + {:ok, %Object{} = object} = ActivityPub.upload(file, description: "a cool file") + assert object.data["name"] == "a cool file" + end + + test "it sets the default description depending on the configuration", %{test_file: file} do + clear_config([Pleroma.Upload, :default_description]) + + Pleroma.Config.put([Pleroma.Upload, :default_description], nil) + {:ok, %Object{} = object} = ActivityPub.upload(file) + assert object.data["name"] == "" + + Pleroma.Config.put([Pleroma.Upload, :default_description], :filename) + {:ok, %Object{} = object} = ActivityPub.upload(file) + assert object.data["name"] == "an_image.jpg" + + Pleroma.Config.put([Pleroma.Upload, :default_description], "unnamed attachment") + {:ok, %Object{} = object} = ActivityPub.upload(file) + assert object.data["name"] == "unnamed attachment" + end + + test "copies the file to the configured folder", %{test_file: file} do + clear_config([Pleroma.Upload, :default_description], :filename) {:ok, %Object{} = object} = ActivityPub.upload(file) assert object.data["name"] == "an_image.jpg" end |