test(status_view): cover attachments with zero dimensions
This commit is contained in:
parent
9443aba06c
commit
283035ad4f
2 changed files with 19 additions and 0 deletions
1
changelog.d/attachment-zero-size.fix
Normal file
1
changelog.d/attachment-zero-size.fix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Do not crash when rendering attachments with zero width or height
|
||||
|
|
@ -597,6 +597,24 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
end
|
||||
|
||||
describe "attachments" do
|
||||
test "skips meta for zero dimensions" do
|
||||
for {width, height} <- [{0, 0}, {200, 0}, {0, 100}] do
|
||||
object = %{
|
||||
"type" => "Image",
|
||||
"url" => [
|
||||
%{
|
||||
"mediaType" => "image/png",
|
||||
"href" => "someurl",
|
||||
"width" => width,
|
||||
"height" => height
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
refute Map.has_key?(StatusView.render("attachment.json", %{attachment: object}), :meta)
|
||||
end
|
||||
end
|
||||
|
||||
test "Complete Mastodon style" do
|
||||
object = %{
|
||||
"type" => "Image",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue