Skip to content

Commit

Permalink
Add attachable to landing_page model, presenter
Browse files Browse the repository at this point in the history
  • Loading branch information
KludgeKML committed Oct 28, 2024
1 parent db797c1 commit 70e6e87
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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
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

Check failure on line 85 in test/unit/app/presenters/publishing_api/landing_page_presenter_test.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/TrailingEmptyLines: Final newline missing. (https://rubystyle.guide#newline-eof)

0 comments on commit 70e6e87

Please sign in to comment.