diff options
| author | lain <lain@soykaf.club> | 2020-05-21 15:08:56 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-05-21 15:08:56 +0200 | 
| commit | cc0d462e91dd29c834c56b82e02022e1babda369 (patch) | |
| tree | f35287bc7b84d60df4074fd630a7c77d0e60f5aa /test | |
| parent | 814c3e51714b2a7de30ed751a6aef361fc712807 (diff) | |
| download | pleroma-cc0d462e91dd29c834c56b82e02022e1babda369.tar.gz pleroma-cc0d462e91dd29c834c56b82e02022e1babda369.zip  | |
Attachments: Have the mediaType on the root, too.
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/activity_pub/object_validator_test.exs | 23 | 
1 files changed, 23 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs index ed6b84e8e..f9990bd2c 100644 --- a/test/web/activity_pub/object_validator_test.exs +++ b/test/web/activity_pub/object_validator_test.exs @@ -25,6 +25,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do        assert {:ok, attachment} =                 AttachmentValidator.cast_and_validate(attachment)                 |> Ecto.Changeset.apply_action(:insert) + +      assert attachment.mediaType == "application/octet-stream"      end      test "it turns mastodon attachments into our attachments" do @@ -48,6 +50,27 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do                   mediaType: "image/jpeg"                 }               ] = attachment.url + +      assert attachment.mediaType == "image/jpeg" +    end + +    test "it handles our own uploads" do +      user = insert(:user) + +      file = %Plug.Upload{ +        content_type: "image/jpg", +        path: Path.absname("test/fixtures/image.jpg"), +        filename: "an_image.jpg" +      } + +      {:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id) + +      {:ok, attachment} = +        attachment.data +        |> AttachmentValidator.cast_and_validate() +        |> Ecto.Changeset.apply_action(:insert) + +      assert attachment.mediaType == "image/jpeg"      end    end  | 
