From 8f3f58e3010fa7c923b77b7d2050175890b58f9b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 21 Jul 2026 23:17:56 +0200 Subject: Render PDF headlines as document cards, not lightbox images A starred PDF previously ran through the same crop-and-lightbox path a photo does -- exactly the awkward treatment explicit headline designation was meant to avoid. _headline_image.html.erb now branches on @headline_asset.pdf?: a PDF renders as a linked card (a :medium thumbnail, a file icon, its name), no gallery participation at all. The existing image-headline and gallery-fallback logic is otherwise unchanged, now scoped to an image-specific headline only. Other attached PDFs -- headlined or not -- list below as plain links, same reasoning as why non-headline photos still get a gallery trigger: an attached document shouldn't go invisible just because nothing's been starred yet. headline_image's own render guard needed widening to cover a page with PDFs attached but no images and no headline at all -- the one case none of the existing conditions accounted for. --- test/models/helpers/content_helper_test.rb | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'test') diff --git a/test/models/helpers/content_helper_test.rb b/test/models/helpers/content_helper_test.rb index d6c7b43..c69ef4e 100644 --- a/test/models/helpers/content_helper_test.rb +++ b/test/models/helpers/content_helper_test.rb @@ -79,4 +79,50 @@ class ContentHelperTest < ActionView::TestCase I18n.with_locale(:en) { assert_match t(:open_gallery), headline_image } end + + test "headline_image renders a document card for a PDF headline, not a lightbox image" do + node = Node.root.children.create!(:slug => "headline_image_pdf_test") + asset = Asset.create!(:name => "Expert Opinion", :upload_content_type => "application/pdf") + node.draft.assets << asset + node.draft.related_assets.find_by(:asset_id => asset.id).update!(:headline => true) + @page = node.draft + + result = headline_image + + assert_match "headline_document_card", result + assert_match "Expert Opinion", result + assert_no_match "data-gallery", result + end + + test "headline_image lists other attached PDFs below the headline" do + node = Node.root.children.create!(:slug => "headline_image_multi_pdf_test") + headline_pdf = Asset.create!(:name => "Main Filing", :upload_content_type => "application/pdf") + other_pdf = Asset.create!(:name => "Supplementary Exhibit", :upload_content_type => "application/pdf") + node.draft.assets << headline_pdf + node.draft.assets << other_pdf + node.draft.related_assets.find_by(:asset_id => headline_pdf.id).update!(:headline => true) + @page = node.draft + + result = headline_image + + assert_match "Main Filing", result + assert_match "Supplementary Exhibit", result + assert_match "headline_document_card", result + assert_match "related_documents_list", result + end + + test "headline_image lists attached PDFs even with no headline chosen" do + node = Node.root.children.create!(:slug => "headline_image_pdf_no_headline_test") + pdf_a = Asset.create!(:name => "Document A", :upload_content_type => "application/pdf") + pdf_b = Asset.create!(:name => "Document B", :upload_content_type => "application/pdf") + node.draft.assets << pdf_a + node.draft.assets << pdf_b + @page = node.draft + + result = headline_image + + assert_no_match "headline_document_card", result + assert_match "Document A", result + assert_match "Document B", result + end end -- cgit v1.3