diff --git a/app/presenters/edition_presenter.rb b/app/presenters/edition_presenter.rb index ff7dbf91f..c98e20bae 100644 --- a/app/presenters/edition_presenter.rb +++ b/app/presenters/edition_presenter.rb @@ -152,6 +152,7 @@ def document "id" => SecureRandom.uuid, "url" => edition.document["file_url"], "content_type" => edition.document["content_type"], + "file_size" => edition.document["size"], } end end diff --git a/spec/presenters/edition_presenter_spec.rb b/spec/presenters/edition_presenter_spec.rb index 8c9ba643a..7e87a29ff 100644 --- a/spec/presenters/edition_presenter_spec.rb +++ b/spec/presenters/edition_presenter_spec.rb @@ -214,5 +214,28 @@ expect(presented_data["last_edited_by_editor_id"]).to eq(user.uid) end end + + describe "document field" do + let(:document_details) { presented_data["details"]["document"] } + + context "when the edition has a document" do + before do + allow(edition).to receive(:document).and_return( + "file_url" => "https://assets.example.com/map.pdf", + "content_type" => "application/pdf", + "size" => 201_672, + ) + end + + it "includes the file size in the document details" do + expect(document_details).to include( + "file_size" => 201_672, + "url" => "https://assets.example.com/map.pdf", + "content_type" => "application/pdf", + "attachment_type" => "file", + ) + end + end + end end end