diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 23:17:56 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-21 23:17:56 +0200 |
| commit | 8f3f58e3010fa7c923b77b7d2050175890b58f9b (patch) | |
| tree | ece76f69129b8b6c3c59b0b71f69e9fc59950d30 /test/models | |
| parent | 18114a978b7c037da5194c48f860435e261f9a0b (diff) | |
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.
Diffstat (limited to 'test/models')
| -rw-r--r-- | test/models/helpers/content_helper_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
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 | |||
| 79 | 79 | ||
| 80 | I18n.with_locale(:en) { assert_match t(:open_gallery), headline_image } | 80 | I18n.with_locale(:en) { assert_match t(:open_gallery), headline_image } |
| 81 | end | 81 | end |
| 82 | |||
| 83 | test "headline_image renders a document card for a PDF headline, not a lightbox image" do | ||
| 84 | node = Node.root.children.create!(:slug => "headline_image_pdf_test") | ||
| 85 | asset = Asset.create!(:name => "Expert Opinion", :upload_content_type => "application/pdf") | ||
| 86 | node.draft.assets << asset | ||
| 87 | node.draft.related_assets.find_by(:asset_id => asset.id).update!(:headline => true) | ||
| 88 | @page = node.draft | ||
| 89 | |||
| 90 | result = headline_image | ||
| 91 | |||
| 92 | assert_match "headline_document_card", result | ||
| 93 | assert_match "Expert Opinion", result | ||
| 94 | assert_no_match "data-gallery", result | ||
| 95 | end | ||
| 96 | |||
| 97 | test "headline_image lists other attached PDFs below the headline" do | ||
| 98 | node = Node.root.children.create!(:slug => "headline_image_multi_pdf_test") | ||
| 99 | headline_pdf = Asset.create!(:name => "Main Filing", :upload_content_type => "application/pdf") | ||
| 100 | other_pdf = Asset.create!(:name => "Supplementary Exhibit", :upload_content_type => "application/pdf") | ||
| 101 | node.draft.assets << headline_pdf | ||
| 102 | node.draft.assets << other_pdf | ||
| 103 | node.draft.related_assets.find_by(:asset_id => headline_pdf.id).update!(:headline => true) | ||
| 104 | @page = node.draft | ||
| 105 | |||
| 106 | result = headline_image | ||
| 107 | |||
| 108 | assert_match "Main Filing", result | ||
| 109 | assert_match "Supplementary Exhibit", result | ||
| 110 | assert_match "headline_document_card", result | ||
| 111 | assert_match "related_documents_list", result | ||
| 112 | end | ||
| 113 | |||
| 114 | test "headline_image lists attached PDFs even with no headline chosen" do | ||
| 115 | node = Node.root.children.create!(:slug => "headline_image_pdf_no_headline_test") | ||
| 116 | pdf_a = Asset.create!(:name => "Document A", :upload_content_type => "application/pdf") | ||
| 117 | pdf_b = Asset.create!(:name => "Document B", :upload_content_type => "application/pdf") | ||
| 118 | node.draft.assets << pdf_a | ||
| 119 | node.draft.assets << pdf_b | ||
| 120 | @page = node.draft | ||
| 121 | |||
| 122 | result = headline_image | ||
| 123 | |||
| 124 | assert_no_match "headline_document_card", result | ||
| 125 | assert_match "Document A", result | ||
| 126 | assert_match "Document B", result | ||
| 127 | end | ||
| 82 | end | 128 | end |
