summaryrefslogtreecommitdiff
path: root/test/models
diff options
context:
space:
mode:
Diffstat (limited to 'test/models')
-rw-r--r--test/models/helpers/content_helper_test.rb46
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
82end 128end