Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attachable to LandingPage model #9552

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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