<%= render "attachments",
title: t("publication.documents", count: 5), # This should always be pluralised.
diff --git a/test/integration/consultation_test.rb b/test/integration/consultation_test.rb
index 9fb6883e8..ac6c44cab 100644
--- a/test/integration/consultation_test.rb
+++ b/test/integration/consultation_test.rb
@@ -127,8 +127,7 @@ class ConsultationTest < ActionDispatch::IntegrationTest
test "consultation that only applies to a set of nations" do
setup_and_visit_content_item("consultation_outcome_with_feedback")
-
- assert_has_important_metadata("Applies to": "England")
+ assert_has_devolved_nations_component("Applies to England")
end
test "ways to respond renders" do
diff --git a/test/integration/detailed_guide_test.rb b/test/integration/detailed_guide_test.rb
index ba8008b12..67f8561ac 100644
--- a/test/integration/detailed_guide_test.rb
+++ b/test/integration/detailed_guide_test.rb
@@ -46,16 +46,17 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
test "detailed guide that only applies to a set of nations" do
setup_and_visit_content_item("national_applicability_detailed_guide")
- assert_has_important_metadata("Applies to:": "England")
+ assert_has_devolved_nations_component("Applies to England")
end
test "detailed guide that only applies to a set of nations, with alternative urls" do
setup_and_visit_content_item("national_applicability_alternative_url_detailed_guide")
-
- assert_has_important_metadata(
- 'Applies to:':
- "England, Scotland, and Wales (see guidance for Northern Ireland)",
- )
+ assert_has_devolved_nations_component("Applies to England, Scotland and Wales", [
+ {
+ text: "Northern Ireland",
+ alternative_url: "http://www.dardni.gov.uk/news-dard-pa022-a-13-new-procedure-for",
+ },
+ ])
end
test "translated detailed guide" do
diff --git a/test/integration/publication_test.rb b/test/integration/publication_test.rb
index 6e4f02af5..b4b552386 100644
--- a/test/integration/publication_test.rb
+++ b/test/integration/publication_test.rb
@@ -76,15 +76,19 @@ class PublicationTest < ActionDispatch::IntegrationTest
test "renders 'Applies to' block in important metadata when there are excluded nations" do
setup_and_visit_content_item("statistics_publication")
-
- assert_has_important_metadata(
- "Applies to": {
- "England (see publications for Northern Ireland, Scotland, and Wales)": nil,
- "Northern Ireland":
- "http://www.dsdni.gov.uk/index/stats_and_research/stats-publications/stats-housing-publications/housing_stats.htm",
- "Scotland": "http://www.scotland.gov.uk/Topics/Statistics/Browse/Housing-Regeneration/HSfS",
- "Wales": "http://wales.gov.uk/topics/statistics/headlines/housing2012/121025/?lang=en",
+ assert_has_devolved_nations_component("Applies to England", [
+ {
+ text: "Northern Ireland",
+ alternative_url: "http://www.dsdni.gov.uk/index/stats_and_research/stats-publications/stats-housing-publications/housing_stats.htm",
},
- )
+ {
+ text: "Scotland",
+ alternative_url: "http://www.scotland.gov.uk/Topics/Statistics/Browse/Housing-Regeneration/HSfS",
+ },
+ {
+ text: "Wales",
+ alternative_url: "http://wales.gov.uk/topics/statistics/headlines/housing2012/121025/?lang=en",
+ },
+ ])
end
end
diff --git a/test/presenters/consultation_presenter_test.rb b/test/presenters/consultation_presenter_test.rb
index 995241b7d..4bdc140cf 100644
--- a/test/presenters/consultation_presenter_test.rb
+++ b/test/presenters/consultation_presenter_test.rb
@@ -96,7 +96,10 @@ def schema_name
presented = presented_item("consultation_outcome_with_feedback")
assert example["details"].include?("national_applicability")
- assert_equal presented.applies_to, "England"
+ assert_equal(presented.national_applicability[:england][:applicable], true)
+ assert_equal(presented.national_applicability[:northern_ireland][:applicable], false)
+ assert_equal(presented.national_applicability[:scotland][:applicable], false)
+ assert_equal(presented.national_applicability[:wales][:applicable], false)
end
test "presents ways to respond" do
diff --git a/test/presenters/detailed_guide_presenter_test.rb b/test/presenters/detailed_guide_presenter_test.rb
index be23553d9..99d18ac0d 100644
--- a/test/presenters/detailed_guide_presenter_test.rb
+++ b/test/presenters/detailed_guide_presenter_test.rb
@@ -50,15 +50,22 @@ def schema_name
presented = presented_item("national_applicability_detailed_guide")
assert example["details"].include?("national_applicability")
- assert_equal presented.applies_to, "England"
+ assert_equal(presented.national_applicability[:england][:applicable], true)
+ assert_equal(presented.national_applicability[:northern_ireland][:applicable], false)
+ assert_equal(presented.national_applicability[:scotland][:applicable], false)
+ assert_equal(presented.national_applicability[:wales][:applicable], false)
end
- test "content can apply only to a set of nations with alternative urls" do
+ test "content can apply only to a set of nations (with alternative URLs where applicable)" do
example = schema_item("national_applicability_alternative_url_detailed_guide")
presented = presented_item("national_applicability_alternative_url_detailed_guide")
assert example["details"].include?("national_applicability")
- assert_equal presented.applies_to, 'England, Scotland, and Wales (see guidance for Northern Ireland)'
+ assert_equal(presented.national_applicability[:england][:applicable], true)
+ assert_equal(presented.national_applicability[:northern_ireland][:applicable], false)
+ assert_equal(presented.national_applicability[:northern_ireland][:alternative_url], "http://www.dardni.gov.uk/news-dard-pa022-a-13-new-procedure-for")
+ assert_equal(presented.national_applicability[:scotland][:applicable], true)
+ assert_equal(presented.national_applicability[:wales][:applicable], true)
end
test "context in title is overridden to display as guidance" do
diff --git a/test/presenters/publication_presenter_test.rb b/test/presenters/publication_presenter_test.rb
index af5148c69..b5cc1b306 100644
--- a/test/presenters/publication_presenter_test.rb
+++ b/test/presenters/publication_presenter_test.rb
@@ -61,14 +61,17 @@ def schema_name
assert_equal '', presented.withdrawal_notice_component[:time]
end
- test "content can apply only to a set of nations (with alternative urls when provided)" do
+ test "content can apply only to a set of nations (with alternative URLs where applicable)" do
example = schema_item("statistics_publication")
presented = presented_item("statistics_publication")
assert example["details"].include?("national_applicability")
- assert_equal(
- presented.applies_to,
- 'England (see publications for Northern Ireland, Scotland, and Wales)',
- )
+ assert_equal(presented.national_applicability[:england][:applicable], true)
+ assert_equal(presented.national_applicability[:northern_ireland][:applicable], false)
+ assert_equal(presented.national_applicability[:northern_ireland][:alternative_url], "http://www.dsdni.gov.uk/index/stats_and_research/stats-publications/stats-housing-publications/housing_stats.htm")
+ assert_equal(presented.national_applicability[:scotland][:applicable], false)
+ assert_equal(presented.national_applicability[:scotland][:alternative_url], "http://www.scotland.gov.uk/Topics/Statistics/Browse/Housing-Regeneration/HSfS")
+ assert_equal(presented.national_applicability[:wales][:applicable], false)
+ assert_equal(presented.national_applicability[:wales][:alternative_url], "http://wales.gov.uk/topics/statistics/headlines/housing2012/121025/?lang=en")
end
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index fcc887260..4ff8a73b6 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -148,6 +148,15 @@ def assert_has_important_metadata(metadata)
end
end
+ def assert_has_devolved_nations_component(text, nations = nil)
+ within(".gem-c-devolved-nations") do
+ assert page.has_text?(text)
+ nations&.each do |nation|
+ assert page.has_link?("Guidance for #{nation[:text]}", href: nation[:alternative_url])
+ end
+ end
+ end
+
def assert_footer_has_published_dates(first_published = nil, last_updated = nil, history_link: false)
assert_has_published_dates(first_published, last_updated, history_link: history_link)
end