Skip to content

Commit

Permalink
Merge pull request #9552 from alphagov/landing-page-attachments
Browse files Browse the repository at this point in the history
Add attachable to LandingPage model
  • Loading branch information
KludgeKML authored Oct 29, 2024
2 parents 951a2d1 + a212e4a commit c7478f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/landing_page.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class LandingPage < Edition
include ::Attachable
include Edition::Organisations

skip_callback :validation, :before, :update_document_slug
Expand Down
1 change: 1 addition & 0 deletions app/presenters/publishing_api/landing_page_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def document_type

def details
YAML.load(item.body, permitted_classes: [Date])
.merge(PayloadBuilder::Attachments.for(item))
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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

0 comments on commit c7478f8

Please sign in to comment.