Add filesize to file entity, expose it to GraphQL API
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -21,7 +21,9 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
|
||||
picture(id: "#{id}") {
|
||||
name,
|
||||
alt,
|
||||
url
|
||||
url,
|
||||
content_type,
|
||||
size
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -32,6 +34,11 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
|
||||
|
||||
assert json_response(res, 200)["data"]["picture"]["name"] == picture.file.name
|
||||
|
||||
assert json_response(res, 200)["data"]["picture"]["content_type"] ==
|
||||
picture.file.content_type
|
||||
|
||||
assert json_response(res, 200)["data"]["picture"]["size"] == 13_120
|
||||
|
||||
assert json_response(res, 200)["data"]["picture"]["url"] =~
|
||||
MobilizonWeb.Endpoint.url()
|
||||
end
|
||||
@@ -68,7 +75,9 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
|
||||
actor_id: #{actor.id}
|
||||
) {
|
||||
url,
|
||||
name
|
||||
name,
|
||||
content_type,
|
||||
size
|
||||
}
|
||||
}
|
||||
"""
|
||||
@@ -91,6 +100,8 @@ defmodule MobilizonWeb.Resolvers.PictureResolverTest do
|
||||
)
|
||||
|
||||
assert json_response(res, 200)["data"]["uploadPicture"]["name"] == picture.name
|
||||
assert json_response(res, 200)["data"]["uploadPicture"]["content_type"] == "image/png"
|
||||
assert json_response(res, 200)["data"]["uploadPicture"]["size"] == 10_097
|
||||
assert json_response(res, 200)["data"]["uploadPicture"]["url"]
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,11 @@ defmodule Mobilizon.UploadTest do
|
||||
|
||||
{:ok, data} = Upload.store(file)
|
||||
|
||||
assert %{"url" => [%{"href" => url}]} = data
|
||||
assert %{
|
||||
"url" => [%{"href" => url, "mediaType" => "image/jpeg"}],
|
||||
"size" => 13_227,
|
||||
"type" => "Image"
|
||||
} = data
|
||||
|
||||
assert String.starts_with?(url, MobilizonWeb.Endpoint.url() <> "/media/")
|
||||
end
|
||||
|
||||
@@ -174,7 +174,8 @@ defmodule Mobilizon.Factory do
|
||||
%Mobilizon.Media.File{
|
||||
name: "My Picture",
|
||||
url: MobilizonWeb.Endpoint.url() <> "/uploads/something",
|
||||
content_type: "image/png"
|
||||
content_type: "image/png",
|
||||
size: 13_120
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user