diff --git a/app/models/landing_page.rb b/app/models/landing_page.rb index 1f1ba7b8bbe..264d329c515 100644 --- a/app/models/landing_page.rb +++ b/app/models/landing_page.rb @@ -1,4 +1,5 @@ class LandingPage < Edition + include ::Attachable include Edition::Organisations skip_callback :validation, :before, :update_document_slug diff --git a/app/presenters/publishing_api/landing_page_presenter.rb b/app/presenters/publishing_api/landing_page_presenter.rb index 8c46d9239bc..7e5c9624937 100644 --- a/app/presenters/publishing_api/landing_page_presenter.rb +++ b/app/presenters/publishing_api/landing_page_presenter.rb @@ -48,6 +48,7 @@ def document_type def details YAML.load(item.body, permitted_classes: [Date]) + .merge(PayloadBuilder::Attachments.for(item)) end end end diff --git a/test/unit/app/presenters/publishing_api/landing_page_presenter_test.rb b/test/unit/app/presenters/publishing_api/landing_page_presenter_test.rb index 7184e327d12..b94d7ebf66e 100644 --- a/test/unit/app/presenters/publishing_api/landing_page_presenter_test.rb +++ b/test/unit/app/presenters/publishing_api/landing_page_presenter_test.rb @@ -7,6 +7,7 @@ class PublishingApi::LandingPagePresenterTest < ActiveSupport::TestCase document: create(:document, id: 12_345, slug: "/landing-page/test"), title: "Landing Page title", summary: "Landing Page summary", + attachments: [create(:file_attachment)], first_published_at: @first_published_at = Time.zone.now, updated_at: 1.year.ago, ) @@ -75,4 +76,10 @@ class PublishingApi::LandingPagePresenterTest < ActiveSupport::TestCase expected_links = {} assert expected_links, @presented_content[:links] end + + test "it presents attachments" do + attachment = @landing_page.attachments.first + assert_equal @presented_content.dig(:details, :attachments, 0, :id), + attachment.id.to_s + end end