Skip to content

Commit cf1efc7

Browse files
authored
Merge pull request #2460 from alphagov/expose-national-applicability-info-on-html-attachments
Expose national applicability information for HMTL Attachments
2 parents a12dc0c + 9e05896 commit cf1efc7

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

app/presenters/html_publication_presenter.rb

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class HtmlPublicationPresenter < ContentItemPresenter
33
include ContentItem::OrganisationBranding
44
include ContentItem::ContentsList
55
include ContentItem::Political
6+
include ContentItem::NationalApplicability
67

78
def isbn
89
content_item["details"]["isbn"]

app/views/content_items/html_publication.html.erb

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
<%= render 'shared/history_notice', content_item: @content_item %>
4646
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
4747

48+
<div class="govuk-grid-row">
49+
<div class="govuk-grid-column-two-thirds">
50+
<%= render "govuk_publishing_components/components/devolved_nations", {
51+
national_applicability: @content_item.national_applicability || {},
52+
type: @content_item.schema_name
53+
} %>
54+
</div>
55+
</div>
56+
4857
<div
4958
class="govuk-grid-row sidebar-with-body"
5059
data-module="sticky-element-container"

test/integration/html_publication_test.rb

+10
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,14 @@ def assert_has_component_organisation_logo_with_brand(brand, index = 1)
116116
setup_and_visit_html_publication("published")
117117
assert_not page.has_css?(".gem-c-single-page-notification-button")
118118
end
119+
120+
test "HTML publication that only applies to a set of nations, with alternative urls" do
121+
setup_and_visit_content_item("national_applicability_alternative_url_html_publication")
122+
assert_has_devolved_nations_component("Applies to England, Scotland and Wales", [
123+
{
124+
text: "Publication for Northern Ireland",
125+
alternative_url: "http://www.dardni.gov.uk/news-dard-pa022-a-13-new-procedure-for",
126+
},
127+
])
128+
end
119129
end

test/presenters/html_publication_presenter_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ def schema_name
99
assert presented_item("published").is_a?(ContentItem::Political)
1010
end
1111

12+
test "includes NationalApplicability" do
13+
assert presented_item("published").is_a?(ContentItem::NationalApplicability)
14+
end
15+
1216
test "presents the basic details of a content item" do
1317
assert_equal schema_item("published")["schema_name"], presented_item("published").schema_name
1418
assert_equal schema_item("published")["links"]["parent"][0]["document_type"], presented_item("published").format_sub_type

0 commit comments

Comments
 (0)