-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3058 from alphagov/tracking-details
Convert publications to local rendering
- Loading branch information
Showing
5 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<% | ||
attachments ||= nil | ||
featured_attachments ||= [] | ||
attachment_details = featured_attachments.filter_map { |id| @content_item&.attachment_details(id) } | ||
%> | ||
<section id="<%= title.parameterize %>"> | ||
<%= render 'govuk_publishing_components/components/heading', | ||
text: title, | ||
mobile_top_margin: true | ||
%> | ||
<% if attachment_details.length > 0 %> | ||
<% add_gem_component_stylesheet("details") %> | ||
<% attachment_details.each do |details| %> | ||
<%= render 'govuk_publishing_components/components/attachment', { | ||
heading_level: 3, | ||
attachment: details, | ||
margin_bottom: 6 | ||
} %> | ||
<% end %> | ||
<% end %> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,12 +32,38 @@ class PublicationTest < ActionDispatch::IntegrationTest | |
assert_footer_has_published_dates("Published 3 May 2016") | ||
end | ||
|
||
test "renders document attachments (as-is and directly)" do | ||
setup_and_visit_content_item("publication") | ||
test "does not render non-featured attachments" do | ||
overrides = { | ||
"details" => { | ||
"attachments" => [{ | ||
"accessible" => false, | ||
"alternative_format_contact_email" => "[email protected]", | ||
"attachment_type" => "file", | ||
"command_paper_number" => "", | ||
"content_type" => "application/pdf", | ||
"file_size" => 123_456, | ||
"filename" => "veolia-permit.pdf", | ||
"hoc_paper_number" => "", | ||
"id" => "violia-permit", | ||
"isbn" => "", | ||
"locale" => "en", | ||
"title" => "Permit: Veolia ES (UK) Limited", | ||
"unique_reference" => "", | ||
"unnumbered_command_paper" => false, | ||
"unnumbered_hoc_paper" => false, | ||
"url" => "https://assets.publishing.service.gov.uk/media/123abc/veolia-permit.zip", | ||
}], | ||
"featured_attachments" => [], | ||
}, | ||
} | ||
|
||
setup_and_visit_content_item("publication", overrides) | ||
within "#documents" do | ||
assert page.has_text?("Permit: Veolia ES (UK) Limited") | ||
assert page.has_no_text?("Permit: Veolia ES (UK) Limited") | ||
end | ||
end | ||
|
||
test "renders featured document attachments using components" do | ||
setup_and_visit_content_item("publication-with-featured-attachments") | ||
within "#documents" do | ||
assert page.has_text?("Number of ex-regular service personnel now part of FR20") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters