"
end
- test 'notice title presents only in English, even if locale is set to another language' do
+ test "notice title presents only in English, even if locale is set to another language" do
# This is to prevent the withdrawal notices on translated editions
# displaying a combination of languages in their titles.
class << @withdrawable
def schema_name
- 'publication'
+ "publication"
end
def content_item
{
- 'title' => 'Proportion of residents who do any walking or cycling (at local authority level) (CW010)',
- 'withdrawn_notice' => {
- 'explanation' => '
',
- 'withdrawn_at' => '2016-07-12T09:47:15Z'
+ "title" => "Proportion of residents who do any walking or cycling (at local authority level) (CW010)",
+ "withdrawn_notice" => {
+ "explanation" => '
',
+ "withdrawn_at" => "2016-07-12T09:47:15Z",
},
- 'locale': 'cy'
+ 'locale': "cy",
}
end
end
diff --git a/test/presenters/content_item_presenter_test.rb b/test/presenters/content_item_presenter_test.rb
index b5ed60b20..6365780b0 100644
--- a/test/presenters/content_item_presenter_test.rb
+++ b/test/presenters/content_item_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'test_helper'
+require "test_helper"
class ContentItemPresenterTest < ActiveSupport::TestCase
test "#title" do
@@ -26,29 +26,29 @@ class ContentItemPresenterTest < ActiveSupport::TestCase
end
test "#canonical_url with a part" do
- example_with_parts = govuk_content_schema_example('travel_advice', 'full-country')
- request_path = example_with_parts['base_path'] + '/safety-and-security'
+ example_with_parts = govuk_content_schema_example("travel_advice", "full-country")
+ request_path = example_with_parts["base_path"] + "/safety-and-security"
presented_example = TravelAdvicePresenter.new(example_with_parts, request_path)
assert_equal "https://www.test.gov.uk/foreign-travel-advice/albania/safety-and-security", presented_example.canonical_url
end
test "available_translations sorts languages by locale with English first" do
- translated = govuk_content_schema_example('case_study', 'translated')
+ translated = govuk_content_schema_example("case_study", "translated")
locales = ContentItemPresenter.new(translated).available_translations
assert_equal %w(en ar es), (locales.map { |t| t[:locale] })
end
test "available_translations returns native locale names using native_language_name_for" do
- translated = govuk_content_schema_example('case_study', 'translated')
+ translated = govuk_content_schema_example("case_study", "translated")
locales = ContentItemPresenter.new(translated).available_translations
assert_equal %w(English العربية Español), (locales.map { |t| t[:text] })
end
test "part slug is nil when requesting a content item without parts" do
- example_without_parts = govuk_content_schema_example('case_study', 'translated')
- presented_example = ContentItemPresenter.new(example_without_parts, example_without_parts['base_path'])
+ example_without_parts = govuk_content_schema_example("case_study", "translated")
+ presented_example = ContentItemPresenter.new(example_without_parts, example_without_parts["base_path"])
refute presented_example.requesting_a_part?
assert presented_example.part_slug.nil?
diff --git a/test/presenters/corporate_information_page_presenter_test.rb b/test/presenters/corporate_information_page_presenter_test.rb
index cf96be6a1..33c25766e 100644
--- a/test/presenters/corporate_information_page_presenter_test.rb
+++ b/test/presenters/corporate_information_page_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class CorporateInformationPagePresenterTest
class PresentedCorporateInformationPage < PresenterTestCase
@@ -6,76 +6,76 @@ def schema_name
"corporate_information_page"
end
- test 'presents the body' do
- assert_equal schema_item['details']['body'], presented_item.body
+ test "presents the body" do
+ assert_equal schema_item["details"]["body"], presented_item.body
end
- test 'presents the organisation in the title' do
+ test "presents the organisation in the title" do
assert_equal "About us - Department of Health", presented_item.page_title
end
- test 'does not present an organisation in the title when it is not present in links' do
+ test "does not present an organisation in the title when it is not present in links" do
presented_item = presented_item(schema_name, "links" => {})
assert_equal "About us", presented_item.page_title
end
- test 'presents withdrawn in the title for withdrawn content' do
+ test "presents withdrawn in the title for withdrawn content" do
presented_item = presented_item(schema_name, "withdrawn_notice" => { "explanation": "Withdrawn", "withdrawn_at": "2014-08-22T10:29:02+01:00" })
assert_equal "[Withdrawn] About us - Department of Health", presented_item.page_title
end
- test 'has contents list' do
+ test "has contents list" do
assert presented_item.is_a?(ContentItem::ContentsList)
end
- test 'has title without context' do
+ test "has title without context" do
assert presented_item.is_a?(ContentItem::TitleAndContext)
title_component_params = { title: "About us", context_locale: :en }
assert_equal title_component_params, presented_item.title_and_context
end
- test 'has organisation branding' do
+ test "has organisation branding" do
assert presented_item.is_a?(ContentItem::OrganisationBranding)
end
- test 'presents corporate information groups on about pages' do
+ test "presents corporate information groups on about pages" do
assert presented_item.is_a?(ContentItem::CorporateInformationGroups)
- expected_contents_list = { text: 'Corporate information', id: 'corporate-information', href: '#corporate-information' }
+ expected_contents_list = { text: "Corporate information", id: "corporate-information", href: "#corporate-information" }
assert_equal expected_contents_list, presented_item.contents.last
assert presented_item.corporate_information?
end
- test 'presents group links that are guids' do
+ test "presents group links that are guids" do
presented_groups = presented_item.corporate_information
assert_equal 'Complaints procedure', presented_groups.first[:links].first
end
- test 'presents group links that are internal links with paths and no GUID' do
+ test "presents group links that are internal links with paths and no GUID" do
presented_groups = presented_item.corporate_information
assert_equal 'Corporate reports', presented_groups.first[:links].last
end
- test 'presents group links that are external' do
+ test "presents group links that are external" do
presented_groups = presented_item.corporate_information
assert_equal 'Jobs', presented_groups.last[:links].last
end
- test 'presents group headings' do
+ test "presents group headings" do
presented_groups = presented_item.corporate_information
assert_equal '
Access our information
', presented_groups.first[:heading]
end
- test 'presents further information based on corporate information page links' do
- publication_scheme = schema_item['links']['corporate_information_pages'].find { |l| l['document_type'] == 'publication_scheme' }
- information_charter = schema_item['links']['corporate_information_pages'].find { |l| l['document_type'] == 'personal_information_charter' }
+ test "presents further information based on corporate information page links" do
+ publication_scheme = schema_item["links"]["corporate_information_pages"].find { |l| l["document_type"] == "publication_scheme" }
+ information_charter = schema_item["links"]["corporate_information_pages"].find { |l| l["document_type"] == "personal_information_charter" }
- assert presented_item.further_information.include?(publication_scheme['base_path'])
- assert presented_item.further_information.include?(publication_scheme['title'])
- assert presented_item.further_information.include?(information_charter['base_path'])
- assert presented_item.further_information.include?(information_charter['title'])
+ assert presented_item.further_information.include?(publication_scheme["base_path"])
+ assert presented_item.further_information.include?(publication_scheme["title"])
+ assert presented_item.further_information.include?(information_charter["base_path"])
+ assert presented_item.further_information.include?(information_charter["title"])
end
end
end
diff --git a/test/presenters/detailed_guide_presenter_test.rb b/test/presenters/detailed_guide_presenter_test.rb
index d99cb4256..2ec436a01 100644
--- a/test/presenters/detailed_guide_presenter_test.rb
+++ b/test/presenters/detailed_guide_presenter_test.rb
@@ -1,27 +1,27 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class DetailedGuidePresenterTest < PresenterTestCase
def schema_name
"detailed_guide"
end
- test 'presents the basic details of a content item' do
- assert_equal schema_item['description'], presented_item.description
- assert_equal schema_item['schema_name'], presented_item.schema_name
- assert_equal schema_item['title'], presented_item.title
- assert_equal schema_item['details']['body'], presented_item.body
+ test "presents the basic details of a content item" do
+ assert_equal schema_item["description"], presented_item.description
+ assert_equal schema_item["schema_name"], presented_item.schema_name
+ assert_equal schema_item["title"], presented_item.title
+ assert_equal schema_item["details"]["body"], presented_item.body
end
- test 'presents a list of contents extracted from headings in the body' do
+ test "presents a list of contents extracted from headings in the body" do
expected_contents_list_item = { text: "The basics", id: "the-basics", href: "#the-basics" }
assert_equal expected_contents_list_item, presented_item.contents[0]
end
- test '#published returns a formatted date of the day the content item became public' do
- assert_equal '12 June 2014', presented_item.published
+ test "#published returns a formatted date of the day the content item became public" do
+ assert_equal "12 June 2014", presented_item.published
end
- test 'presents withdrawn notices' do
+ test "presents withdrawn notices" do
example = schema_item("withdrawn_detailed_guide")
presented = presented_item("withdrawn_detailed_guide")
@@ -31,11 +31,11 @@ def schema_name
assert_equal '', presented.withdrawal_notice_component[:time]
end
- test 'presents the title of the publishing government' do
+ test "presents the title of the publishing government" do
assert_equal schema_item["details"]["government"]["title"], presented_item.publishing_government
end
- test 'content can be historically political' do
+ test "content can be historically political" do
example = schema_item("political_detailed_guide")
presented = presented_item("political_detailed_guide")
@@ -45,34 +45,34 @@ def schema_name
assert presented.historically_political?
end
- test 'content can apply only to a set of nations' do
- example = schema_item('national_applicability_detailed_guide')
- presented = presented_item('national_applicability_detailed_guide')
+ test "content can apply only to a set of nations" do
+ example = schema_item("national_applicability_detailed_guide")
+ presented = presented_item("national_applicability_detailed_guide")
- assert example['details'].include?('national_applicability')
- assert_equal presented.applies_to, 'England'
+ assert example["details"].include?("national_applicability")
+ assert_equal presented.applies_to, "England"
end
- test 'content can apply only to a set of nations with alternative urls' do
- example = schema_item('national_applicability_alternative_url_detailed_guide')
- presented = presented_item('national_applicability_alternative_url_detailed_guide')
+ test "content can apply only to a set of nations with alternative urls" 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 example["details"].include?("national_applicability")
assert_equal presented.applies_to, 'England, Scotland, and Wales (see guidance for Northern Ireland)'
end
- test 'context in title is overridden to display as guidance' do
+ test "context in title is overridden to display as guidance" do
I18n.with_locale("fr") do
assert_equal I18n.t("content_item.schema_name.guidance", count: 1), presented_item.title_and_context[:context]
end
end
- test 'eu structural fund logo is presented where applicable' do
- presented = presented_item('england-2014-to-2020-european-structural-and-investment-funds')
+ test "eu structural fund logo is presented where applicable" do
+ presented = presented_item("england-2014-to-2020-european-structural-and-investment-funds")
expected = {
- alt_text: 'European structural investment funds',
- path: 'https://assets.publishing.service.gov.uk/media/5540ab8aed915d15d8000030/european-structural-investment-funds.png'
+ alt_text: "European structural investment funds",
+ path: "https://assets.publishing.service.gov.uk/media/5540ab8aed915d15d8000030/european-structural-investment-funds.png",
}
assert_equal presented.logo, expected
end
diff --git a/test/presenters/document_collection_presenter_test.rb b/test/presenters/document_collection_presenter_test.rb
index 49286829c..109e75d24 100644
--- a/test/presenters/document_collection_presenter_test.rb
+++ b/test/presenters/document_collection_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class DocumentCollectionPresenterTest
class TestCase < PresenterTestCase
@@ -8,27 +8,27 @@ def schema_name
end
class PresentedDocumentCollection < TestCase
- test 'presents the title' do
- assert_equal schema_item['title'], presented_item.title
+ test "presents the title" do
+ assert_equal schema_item["title"], presented_item.title
end
- test 'presents the description' do
- assert_equal schema_item['description'], presented_item.description
+ test "presents the description" do
+ assert_equal schema_item["description"], presented_item.description
end
- test 'presents the schema name' do
- assert_equal schema_item['schema_name'], presented_item.schema_name
+ test "presents the schema name" do
+ assert_equal schema_item["schema_name"], presented_item.schema_name
end
- test 'presents the body' do
- example = 'document_collection_with_body'
- expected_body = schema_item(example)['details']['body']
+ test "presents the body" do
+ example = "document_collection_with_body"
+ expected_body = schema_item(example)["details"]["body"]
presented_body = presented_item(example).body
assert_equal expected_body, presented_body
end
- test 'presents a contents list based on collection groups' do
+ test "presents a contents list based on collection groups" do
contents = [
{ text: "Car and light van", id: "car-and-light-van", href: "#car-and-light-van" },
{ text: "Moped and motorcycle", id: "moped-and-motorcycle", href: "#moped-and-motorcycle" },
@@ -41,13 +41,13 @@ class PresentedDocumentCollection < TestCase
assert_equal contents, presented_item.contents
end
- test 'presents a group heading with generated ID' do
+ test "presents a group heading with generated ID" do
heading = '
Heading with Spaces
'
assert_equal heading, presented_item.group_heading("title" => "Heading with Spaces")
end
- test 'presents an ordered list of group documents' do
+ test "presents an ordered list of group documents" do
documents = [
{
link: {
@@ -59,22 +59,22 @@ class PresentedDocumentCollection < TestCase
track_label: "/government/publications/national-standard-for-driving-cars-and-light-vans",
track_options: {
dimension28: "1",
- dimension29: "National standard for driving cars and light vans"
- }
- }
+ dimension29: "National standard for driving cars and light vans",
+ },
+ },
},
metadata: {
public_updated_at: Time.zone.parse("2007-03-16 15:00:02 +0000"),
- document_type: "Guidance"
- }
- }
+ document_type: "Guidance",
+ },
+ },
]
document_ids = schema_item["details"]["collection_groups"].first["documents"]
assert_equal documents, presented_item.group_document_links({ "documents" => [document_ids.first] }, 0)
end
- test 'it handles the document type lacking a translation' do
+ test "it handles the document type lacking a translation" do
schema_data = schema_item
document = schema_data["links"]["documents"].first.tap do |link|
@@ -89,7 +89,7 @@ class PresentedDocumentCollection < TestCase
assert_nil grouped.first[:metadata][:document_type]
end
- test 'it handles public_updated_at not being specified' do
+ test "it handles public_updated_at not being specified" do
schema_data = schema_item
document = schema_data["links"]["documents"].first.tap do |link|
@@ -120,7 +120,7 @@ class GroupWithMissingDocument < TestCase
assert_equal(
["/government/publications/national-standard-for-developed-driving-competence"],
- presented_links_base_paths
+ presented_links_base_paths,
)
end
end
@@ -141,7 +141,7 @@ class GroupWithNoDocuments < TestCase
class GroupWithOnlyMissingDocuments < TestCase
test "does not present the group" do
presenter = presented_item(
- "document_collection_with_missing_links_documents"
+ "document_collection_with_missing_links_documents",
)
group_with_missing_documents =
@@ -156,7 +156,7 @@ class GroupWithOnlyMissingDocuments < TestCase
class GroupWithDocumentsWhenThereIsNoLinksDocuments < TestCase
test "does not present the group" do
presenter = presented_item(
- "document_collection_with_group_but_no_documents"
+ "document_collection_with_group_but_no_documents",
)
group_with_missing_documents =
@@ -171,7 +171,7 @@ class GroupWithDocumentsWhenThereIsNoLinksDocuments < TestCase
class GroupWithDocumentsWhenThereAreWithdrawnDocuments < TestCase
test "does not present withdrawn documents" do
presenter = presented_item(
- "document_collection_with_withdrawn_links_documents"
+ "document_collection_with_withdrawn_links_documents",
)
presented_documents = presenter.groups.first["documents"]
@@ -180,7 +180,7 @@ class GroupWithDocumentsWhenThereAreWithdrawnDocuments < TestCase
assert_equal(
presented_documents.size,
- expected_number_of_presented_documents
+ expected_number_of_presented_documents,
)
end
end
diff --git a/test/presenters/fatality_notice_presenter_test.rb b/test/presenters/fatality_notice_presenter_test.rb
index f40d85c10..d549e18b3 100644
--- a/test/presenters/fatality_notice_presenter_test.rb
+++ b/test/presenters/fatality_notice_presenter_test.rb
@@ -1,35 +1,35 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class FatalityNoticePresenterTest < PresenterTestCase
def schema_name
"fatality_notice"
end
- test 'presents the basic details of a content item' do
- assert_equal schema_item['title'], presented_item.title
- assert_equal schema_item['description'], presented_item.description
+ test "presents the basic details of a content item" do
+ assert_equal schema_item["title"], presented_item.title
+ assert_equal schema_item["description"], presented_item.description
end
- test 'presents the field of operation' do
+ test "presents the field of operation" do
assert_equal(
- schema_item['links']['field_of_operation'].first['title'],
- presented_item.field_of_operation.title
+ schema_item["links"]["field_of_operation"].first["title"],
+ presented_item.field_of_operation.title,
)
assert_equal(
- schema_item['links']['field_of_operation'].first['base_path'],
- presented_item.field_of_operation.path
+ schema_item["links"]["field_of_operation"].first["base_path"],
+ presented_item.field_of_operation.path,
)
end
- test 'is linkable' do
+ test "is linkable" do
assert presented_item.is_a?(ContentItem::Linkable)
end
- test 'is updatable' do
+ test "is updatable" do
assert presented_item.is_a?(ContentItem::Updatable)
end
- test 'it presents the body' do
- assert_equal schema_item['details']['body'], presented_item.body
+ test "it presents the body" do
+ assert_equal schema_item["details"]["body"], presented_item.body
end
end
diff --git a/test/presenters/gone_presenter_test.rb b/test/presenters/gone_presenter_test.rb
index af325d087..bc69509bd 100644
--- a/test/presenters/gone_presenter_test.rb
+++ b/test/presenters/gone_presenter_test.rb
@@ -1,13 +1,13 @@
-require 'test_helper'
+require "test_helper"
class GonePresenterTest < ActiveSupport::TestCase
- test 'presents the basic details required to display an gone' do
- assert_equal gone['details']['explanation'], presented_gone.explanation
- assert_equal gone['details']['alternative_path'], presented_gone.alternative_path
+ test "presents the basic details required to display an gone" do
+ assert_equal gone["details"]["explanation"], presented_gone.explanation
+ assert_equal gone["details"]["alternative_path"], presented_gone.alternative_path
end
def gone
- govuk_content_schema_example('gone', 'gone')
+ govuk_content_schema_example("gone", "gone")
end
def presented_gone
diff --git a/test/presenters/guide_presenter_test.rb b/test/presenters/guide_presenter_test.rb
index ce1c1107a..37c24494a 100644
--- a/test/presenters/guide_presenter_test.rb
+++ b/test/presenters/guide_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class GuidePresenterTest
class PresentedGuide < PresenterTestCase
@@ -6,18 +6,18 @@ def schema_name
"guide"
end
- test 'has parts' do
+ test "has parts" do
assert presented_item.is_a?(ContentItem::Parts)
end
test "presents unique page titles for each part" do
- assert_equal presented_item.page_title, schema_item['title']
- schema_item['details']['parts'].each do |part|
- assert_equal presented_item('guide', part['slug']).page_title, "#{schema_item['title']}: #{part['title']}"
+ assert_equal presented_item.page_title, schema_item["title"]
+ schema_item["details"]["parts"].each do |part|
+ assert_equal presented_item("guide", part["slug"]).page_title, "#{schema_item['title']}: #{part['title']}"
end
end
- test 'presents withdrawn in the title for withdrawn content' do
+ test "presents withdrawn in the title for withdrawn content" do
presented_item = presented_item(schema_name, nil, "withdrawn_notice" => { "explanation": "Withdrawn", "withdrawn_at": "2014-08-22T10:29:02+01:00" })
assert_equal "[Withdrawn] The national curriculum", presented_item.page_title
end
@@ -27,73 +27,73 @@ def schema_name
end
test "presents only next navigation when first part" do
- parts = schema_item['details']['parts']
+ parts = schema_item["details"]["parts"]
nav = presented_item.previous_and_next_navigation
expected_nav = {
next_page: {
url: "#{schema_item['base_path']}/#{parts[1]['slug']}",
title: "Next",
- label: parts[1]['title']
- }
+ label: parts[1]["title"],
+ },
}
assert_equal nav, expected_nav
end
test "presents previous and next navigation" do
- parts = schema_item['details']['parts']
- nav = presented_item('guide', parts[1]['slug']).previous_and_next_navigation
+ parts = schema_item["details"]["parts"]
+ nav = presented_item("guide", parts[1]["slug"]).previous_and_next_navigation
expected_nav = {
next_page: {
url: "#{schema_item['base_path']}/#{parts[2]['slug']}",
title: "Next",
- label: parts[2]['title']
+ label: parts[2]["title"],
},
previous_page: {
- url: schema_item['base_path'],
+ url: schema_item["base_path"],
title: "Previous",
- label: parts[0]['title']
- }
+ label: parts[0]["title"],
+ },
}
assert_equal nav, expected_nav
end
test "presents only previous navigation when last part" do
- parts = schema_item['details']['parts']
- nav = presented_item('guide', parts.last['slug']).previous_and_next_navigation
+ parts = schema_item["details"]["parts"]
+ nav = presented_item("guide", parts.last["slug"]).previous_and_next_navigation
expected_nav = {
previous_page: {
url: "#{schema_item['base_path']}/#{parts[-2]['slug']}",
title: "Previous",
- label: parts[-2]['title']
- }
+ label: parts[-2]["title"],
+ },
}
assert_equal nav, expected_nav
end
test "presents no navigation when no other parts" do
- nav = presented_item('single-page-guide').previous_and_next_navigation
+ nav = presented_item("single-page-guide").previous_and_next_navigation
assert_equal nav, {}
end
test "sends an error notification for guide with no parts" do
GovukError.expects(:notify).with(
- 'Guide with no parts',
- extra: { error_message: 'Guide rendered without any parts at /correct-marriage-registration' }
+ "Guide with no parts",
+ extra: { error_message: "Guide rendered without any parts at /correct-marriage-registration" },
)
- presented_item('no-part-guide').has_parts?
+ presented_item("no-part-guide").has_parts?
end
test "presents access tokens in part links when provided" do
- presented = presented_item('guide')
- presented.draft_access_token = 'some_token'
- expected_param = '?token=some_token'
+ presented = presented_item("guide")
+ presented.draft_access_token = "some_token"
+ expected_param = "?token=some_token"
presented.parts.each do |part|
- assert part['full_path'].ends_with?(expected_param)
+ assert part["full_path"].ends_with?(expected_param)
end
presented.parts_navigation.flatten.each_with_index do |link, i|
@@ -114,7 +114,7 @@ def presented_item(type = schema_name, part_slug = nil, overrides = {})
GuidePresenter.new(
schema_example_content_item.merge(overrides),
- "#{schema_example_content_item['base_path']}#{part_slug}"
+ "#{schema_example_content_item['base_path']}#{part_slug}",
)
end
end
diff --git a/test/presenters/help_page_presenter_test.rb b/test/presenters/help_page_presenter_test.rb
index e87fb3a19..af71a73ec 100644
--- a/test/presenters/help_page_presenter_test.rb
+++ b/test/presenters/help_page_presenter_test.rb
@@ -1,15 +1,15 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class HelpPagePresenterTest < PresenterTestCase
def schema_name
"help_page"
end
- test 'presents the title' do
- assert_equal schema_item['title'], presented_item.title
+ test "presents the title" do
+ assert_equal schema_item["title"], presented_item.title
end
- test 'presents the body' do
- assert_equal schema_item['details']['body'], presented_item.body
+ test "presents the body" do
+ assert_equal schema_item["details"]["body"], presented_item.body
end
end
diff --git a/test/presenters/html_publication_presenter_test.rb b/test/presenters/html_publication_presenter_test.rb
index c6dbc4870..10dd34ee6 100644
--- a/test/presenters/html_publication_presenter_test.rb
+++ b/test/presenters/html_publication_presenter_test.rb
@@ -1,29 +1,29 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class HtmlPublicationPresenterTest < PresenterTestCase
def schema_name
"html_publication"
end
- test 'presents the basic details of a content item' do
- assert_equal schema_item("published")['schema_name'], presented_item("published").schema_name
- assert_equal schema_item("published")['links']['parent'][0]['document_type'], presented_item("published").format_sub_type
- assert_equal schema_item("published")['title'], presented_item("published").title
- assert_equal schema_item("published")['details']['body'], presented_item("published").body
+ test "presents the basic details of a content item" do
+ assert_equal schema_item("published")["schema_name"], presented_item("published").schema_name
+ assert_equal schema_item("published")["links"]["parent"][0]["document_type"], presented_item("published").format_sub_type
+ assert_equal schema_item("published")["title"], presented_item("published").title
+ assert_equal schema_item("published")["details"]["body"], presented_item("published").body
end
- test 'presents a list of contents extracted from headings in the body' do
+ test "presents a list of contents extracted from headings in the body" do
expected_contents_list_item = { text: "Details of the application", id: "details-of-the-application", href: "#details-of-the-application" }
assert_equal expected_contents_list_item, presented_item("published").contents[0]
end
- test 'presents the meta data info of a content item' do
- assert_equal schema_item("print_with_meta_data")['details']['isbn'], presented_item("print_with_meta_data").isbn
- assert_equal schema_item("print_with_meta_data")['details']['web_isbn'], presented_item("print_with_meta_data").web_isbn
- assert_equal schema_item("print_with_meta_data")['details']['print_meta_data_contact_address'], presented_item("print_with_meta_data").print_meta_data_contact_address
+ test "presents the meta data info of a content item" do
+ assert_equal schema_item("print_with_meta_data")["details"]["isbn"], presented_item("print_with_meta_data").isbn
+ assert_equal schema_item("print_with_meta_data")["details"]["web_isbn"], presented_item("print_with_meta_data").web_isbn
+ assert_equal schema_item("print_with_meta_data")["details"]["print_meta_data_contact_address"], presented_item("print_with_meta_data").print_meta_data_contact_address
end
- test 'presents the last change date' do
+ test "presents the last change date" do
published = presented_item("published")
assert_equal "Published 17 January 2016", published.last_changed
@@ -31,8 +31,8 @@ def schema_name
assert_equal "Updated 2 February 2016", updated.last_changed
end
- test 'presents the list of organisations' do
- multiple_organisations_html_publication = schema_item('multiple_organisations')
+ test "presents the list of organisations" do
+ multiple_organisations_html_publication = schema_item("multiple_organisations")
organisation_titles = multiple_organisations_html_publication["links"]["organisations"].map { |o| o["title"] }
presented_unordered_html_publication = HtmlPublicationPresenter.new(multiple_organisations_html_publication)
@@ -41,11 +41,11 @@ def schema_name
assert_equal organisation_titles, presented_organisations
end
- test 'has organisation branding' do
+ test "has organisation branding" do
assert presented_item("published").is_a?(ContentItem::OrganisationBranding)
end
- test 'includes custom organisation logos when a single organisation is listed' do
+ test "includes custom organisation logos when a single organisation is listed" do
presented = presented_item("updated")
organisation = presented.organisations.first
example_logo = schema_item("updated")["links"]["organisations"][0]["details"]["logo"]["image"].symbolize_keys
@@ -55,11 +55,11 @@ def schema_name
assert_equal example_logo, presented_logo
end
- test 'hides custom organisation logos when multiple organisations listed together' do
+ test "hides custom organisation logos when multiple organisations listed together" do
presented = presented_item("multiple_organisations")
organisation = presented.organisations.first
organisation["details"]["logo"]["image"] = {
- "url" => "url"
+ "url" => "url",
}
assert presented.organisations.count > 1
diff --git a/test/presenters/news_article_presenter_test.rb b/test/presenters/news_article_presenter_test.rb
index 7dd09d040..dab8c9443 100644
--- a/test/presenters/news_article_presenter_test.rb
+++ b/test/presenters/news_article_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class NewsArticlePresenterTest
class NewsArticlePresenterTestCase < PresenterTestCase
@@ -10,40 +10,40 @@ def schema_name
end
class PresentedNewsArticleTest < NewsArticlePresenterTestCase
- test 'is linkable' do
+ test "is linkable" do
assert presented_item.is_a?(ContentItem::Linkable)
end
- test 'is updatable' do
+ test "is updatable" do
assert presented_item.is_a?(ContentItem::Updatable)
end
- test 'is withdrawable' do
+ test "is withdrawable" do
assert presented_item.is_a?(ContentItem::Withdrawable)
end
- test 'is shareable' do
+ test "is shareable" do
assert presented_item.is_a?(ContentItem::Shareable)
end
- test 'includes political' do
+ test "includes political" do
assert presented_item.is_a?(ContentItem::Political)
end
- test 'presents a description' do
- assert_equal schema_item['description'], presented_item.description
+ test "presents a description" do
+ assert_equal schema_item["description"], presented_item.description
end
- test 'presents a body' do
- assert_equal schema_item['details']['body'], presented_item.body
+ test "presents a body" do
+ assert_equal schema_item["details"]["body"], presented_item.body
end
- test 'presents a readable first published date' do
- assert_equal '25 December 2016', presented_item.published
+ test "presents a readable first published date" do
+ assert_equal "25 December 2016", presented_item.published
end
- test 'presents the locale' do
- assert_equal schema_item['locale'], presented_item.locale
+ test "presents the locale" do
+ assert_equal schema_item["locale"], presented_item.locale
end
end
@@ -52,7 +52,7 @@ def example_schema_name
"news_article_history_mode"
end
- test 'presents historically political' do
+ test "presents historically political" do
assert presented_item(example_schema_name).historically_political?
end
end
@@ -62,8 +62,8 @@ def example_schema_name
"news_article_news_story_translated_arabic"
end
- test 'presents the locale as the translated item locale' do
- assert_equal 'ur', presented_item(example_schema_name).locale
+ test "presents the locale as the translated item locale" do
+ assert_equal "ur", presented_item(example_schema_name).locale
end
end
end
diff --git a/test/presenters/publication_presenter_test.rb b/test/presenters/publication_presenter_test.rb
index b0f17de18..58f0283ee 100644
--- a/test/presenters/publication_presenter_test.rb
+++ b/test/presenters/publication_presenter_test.rb
@@ -1,31 +1,31 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class PublicationPresenterTest < PresenterTestCase
def schema_name
"publication"
end
- test 'presents the basic details of a content item' do
- assert_equal schema_item['description'], presented_item.description
- assert_equal schema_item['schema_name'], presented_item.schema_name
- assert_equal schema_item['title'], presented_item.title
- assert_equal schema_item['details']['body'], presented_item.details
- assert_equal schema_item['details']['documents'].join(''), presented_item.documents
+ test "presents the basic details of a content item" do
+ assert_equal schema_item["description"], presented_item.description
+ assert_equal schema_item["schema_name"], presented_item.schema_name
+ assert_equal schema_item["title"], presented_item.title
+ assert_equal schema_item["details"]["body"], presented_item.details
+ assert_equal schema_item["details"]["documents"].join(""), presented_item.documents
end
- test '#published returns a formatted date of the day the content item became public' do
- assert_equal '3 May 2016', presented_item.published
+ test "#published returns a formatted date of the day the content item became public" do
+ assert_equal "3 May 2016", presented_item.published
end
- test 'counts documents attached to publication' do
+ test "counts documents attached to publication" do
assert_equal 2, presented_item.documents_count
end
- test 'presents the title of the publishing government' do
+ test "presents the title of the publishing government" do
assert_equal schema_item["details"]["government"]["title"], presented_item.publishing_government
end
- test 'content can be historically political' do
+ test "content can be historically political" do
example = schema_item("political_publication")
presented = presented_item("political_publication")
@@ -35,27 +35,27 @@ def schema_name
assert presented.historically_political?
end
- test '#from presents people' do
+ test "#from presents people" do
minister = schema_item["links"]["people"][0]
assert presented_item.from.include?("#{minister['title']}")
end
- test '#part_of presents topical events' do
+ test "#part_of presents topical events" do
event = schema_item["links"]["topical_events"][0]
assert presented_item.part_of.include?("#{event['title']}")
end
- test '#part_of presents related statistical data sets' do
+ test "#part_of presents related statistical data sets" do
data_set = schema_item("statistics_publication")["links"]["related_statistical_data_sets"][0]
assert presented_item("statistics_publication").part_of.include?("#{data_set['title']}")
end
- test '#national_statistics? matches national statistics documents' do
+ test "#national_statistics? matches national statistics documents" do
refute presented_item.national_statistics?
assert presented_item("statistics_publication").national_statistics?
end
- test 'presents withdrawn notices' do
+ test "presents withdrawn notices" do
example = schema_item("withdrawn_publication")
presented = presented_item("withdrawn_publication")
@@ -65,14 +65,14 @@ 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
- example = schema_item('statistics_publication')
- presented = presented_item('statistics_publication')
+ test "content can apply only to a set of nations (with alternative urls when provided)" do
+ example = schema_item("statistics_publication")
+ presented = presented_item("statistics_publication")
- assert example['details'].include?('national_applicability')
+ assert example["details"].include?("national_applicability")
assert_equal(
presented.applies_to,
- 'England (see publications for Northern Ireland, Scotland, and Wales)'
+ 'England (see publications for Northern Ireland, Scotland, and Wales)',
)
end
end
diff --git a/test/presenters/service_sign_in/choose_sign_in_presenter_test.rb b/test/presenters/service_sign_in/choose_sign_in_presenter_test.rb
index 77253249d..dda641b7b 100644
--- a/test/presenters/service_sign_in/choose_sign_in_presenter_test.rb
+++ b/test/presenters/service_sign_in/choose_sign_in_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'test_helper'
+require "test_helper"
class ServiceSignInPresenterTest
class ChooseSignIn < ActiveSupport::TestCase
@@ -19,8 +19,8 @@ def schema_item
@schema_item ||= govuk_content_schema_example(schema_name, schema_name)
end
- test 'presents the schema_name' do
- assert_equal schema_item['schema_name'], @presented_item.schema_name
+ test "presents the schema_name" do
+ assert_equal schema_item["schema_name"], @presented_item.schema_name
end
test "presents the title" do
@@ -48,18 +48,18 @@ def schema_item
assert_equal "option", @presented_item.options_id
end
- test 'presents :or before last radio button option' do
+ test "presents :or before last radio button option" do
assert_equal @presented_item.options[2], :or
end
- test 'presents the back_link' do
- assert_equal schema_item['links']['parent'].first['base_path'], @presented_item.back_link
+ test "presents the back_link" do
+ assert_equal schema_item["links"]["parent"].first["base_path"], @presented_item.back_link
end
- test 'presents the tracking values' do
- assert_equal @choose_sign_in['tracking_code'], @presented_item.tracking_code
- assert_equal @choose_sign_in['tracking_domain'], @presented_item.tracking_domain
- assert_equal @choose_sign_in['tracking_name'], @presented_item.tracking_name
+ test "presents the tracking values" do
+ assert_equal @choose_sign_in["tracking_code"], @presented_item.tracking_code
+ assert_equal @choose_sign_in["tracking_domain"], @presented_item.tracking_domain
+ assert_equal @choose_sign_in["tracking_name"], @presented_item.tracking_name
end
end
end
diff --git a/test/presenters/service_sign_in/create_new_account_presenter_test.rb b/test/presenters/service_sign_in/create_new_account_presenter_test.rb
index 69cff66d9..91d71f832 100644
--- a/test/presenters/service_sign_in/create_new_account_presenter_test.rb
+++ b/test/presenters/service_sign_in/create_new_account_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'test_helper'
+require "test_helper"
class ServiceSignInPresenterTest
class CreateNewAccount < ActiveSupport::TestCase
@@ -20,11 +20,11 @@ def schema_item
end
def parent_slug
- schema_item['details']['choose_sign_in']['slug']
+ schema_item["details"]["choose_sign_in"]["slug"]
end
- test 'presents the schema_name' do
- assert_equal schema_item['schema_name'], @presented_item.schema_name
+ test "presents the schema_name" do
+ assert_equal schema_item["schema_name"], @presented_item.schema_name
end
test "presents the title" do
@@ -35,7 +35,7 @@ def parent_slug
assert_equal @create_new_account["body"], @presented_item.body
end
- test 'presents the back_link' do
+ test "presents the back_link" do
assert_equal "#{schema_item['base_path']}/#{parent_slug}", @presented_item.back_link
end
end
diff --git a/test/presenters/specialist_document_presenter_test.rb b/test/presenters/specialist_document_presenter_test.rb
index 5cbc28e27..a3e096cda 100644
--- a/test/presenters/specialist_document_presenter_test.rb
+++ b/test/presenters/specialist_document_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class SpecialistDocumentPresenterTest
class SpecialistDocumentTestCase < PresenterTestCase
@@ -8,37 +8,37 @@ def schema_name
end
class PresentedSpecialistDocument < SpecialistDocumentTestCase
- test 'presents the schema name' do
- assert_equal schema_item('aaib-reports')['schema_name'], presented_item('aaib-reports').schema_name
+ test "presents the schema name" do
+ assert_equal schema_item("aaib-reports")["schema_name"], presented_item("aaib-reports").schema_name
end
- test 'presents the body' do
- expected_body = schema_item('aaib-reports')['details']['body']
+ test "presents the body" do
+ expected_body = schema_item("aaib-reports")["details"]["body"]
- assert_equal expected_body, presented_item('aaib-reports').body
+ assert_equal expected_body, presented_item("aaib-reports").body
end
- test 'has metadata' do
- assert presented_item('aaib-reports').is_a?(ContentItem::Metadata)
+ test "has metadata" do
+ assert presented_item("aaib-reports").is_a?(ContentItem::Metadata)
end
- test 'presents headers as nested contents (with trailing colons removed)' do
+ test "presents headers as nested contents (with trailing colons removed)" do
expected_headers = [
{ text: "Reports of diabetic acidosis", id: "reports-of-diabetic-acidosis", href: "#reports-of-diabetic-acidosis" },
{ text: "SGLT2 inhibitors – medicines in this class", id: "sglt2-inhibitors--medicines-in-this-class", href: "#sglt2-inhibitors--medicines-in-this-class" },
- { text: "Further information", id: "further-information", href: "#further-information" }
+ { text: "Further information", id: "further-information", href: "#further-information" },
]
- assert_equal expected_headers, presented_item('drug-safety-update').contents
+ assert_equal expected_headers, presented_item("drug-safety-update").contents
end
- test 'presents updates based on change history' do
- example = schema_item('aaib-reports')
+ test "presents updates based on change history" do
+ example = schema_item("aaib-reports")
example["details"]["change_history"] = [
{
"note" => "First published",
- "public_timestamp" => "2003-03-03"
- }
+ "public_timestamp" => "2003-03-03",
+ },
]
refute present_example(example).updated
@@ -46,32 +46,32 @@ class PresentedSpecialistDocument < SpecialistDocumentTestCase
example["details"]["change_history"] = [
{
"note" => "First published",
- "public_timestamp" => "2003-03-03"
+ "public_timestamp" => "2003-03-03",
},
{
"note" => "Modified since first published",
- "public_timestamp" => "2013-04-05"
- }
+ "public_timestamp" => "2013-04-05",
+ },
]
assert present_example(example).updated
end
- test 'presents the published date using the oldest date in the change history (when no first published facet)' do
- example = schema_item('aaib-reports')
+ test "presents the published date using the oldest date in the change history (when no first published facet)" do
+ example = schema_item("aaib-reports")
example["first_published_at"] = "2001-01-01"
example["details"]["change_history"] = [
{
"note" => "Newer",
- "public_timestamp" => "2003-03-03"
+ "public_timestamp" => "2003-03-03",
},
{
"note" => "Oldest",
- "public_timestamp" => "2002-02-02"
+ "public_timestamp" => "2002-02-02",
},
{
"note" => "More recent",
- "public_timestamp" => "2013-03-03"
+ "public_timestamp" => "2013-03-03",
},
]
@@ -79,42 +79,42 @@ class PresentedSpecialistDocument < SpecialistDocumentTestCase
assert Time.parse(presented.published) == Time.parse("2002-02-02")
end
- test 'has title without context' do
- assert presented_item('aaib-reports').is_a?(ContentItem::TitleAndContext)
+ test "has title without context" do
+ assert presented_item("aaib-reports").is_a?(ContentItem::TitleAndContext)
title_component_params = {
- title: schema_item('aaib-reports')['title'],
+ title: schema_item("aaib-reports")["title"],
context_locale: nil,
- average_title_length: 'long',
+ average_title_length: "long",
}
- assert_equal title_component_params, presented_item('aaib-reports').title_and_context
+ assert_equal title_component_params, presented_item("aaib-reports").title_and_context
end
- test 'should not present continuation_link' do
- assert_nil presented_item('aaib-reports').continuation_link
+ test "should not present continuation_link" do
+ assert_nil presented_item("aaib-reports").continuation_link
end
- test 'should not present will_continue_on' do
- assert_nil presented_item('aaib-reports').will_continue_on
+ test "should not present will_continue_on" do
+ assert_nil presented_item("aaib-reports").will_continue_on
end
- test 'should present continuation_link' do
+ test "should present continuation_link" do
assert_equal(
- presented_item('business-finance-support-scheme').continuation_link,
- 'http://www.bigissueinvest.com'
+ presented_item("business-finance-support-scheme").continuation_link,
+ "http://www.bigissueinvest.com",
)
end
- test 'should present will_continue_on' do
+ test "should present will_continue_on" do
assert_equal(
- presented_item('business-finance-support-scheme').will_continue_on,
- 'on the Big Issue Invest website'
+ presented_item("business-finance-support-scheme").will_continue_on,
+ "on the Big Issue Invest website",
)
end
- test 'removes first published dates for bulk published documents' do
- example = schema_item('aaib-reports')
+ test "removes first published dates for bulk published documents" do
+ example = schema_item("aaib-reports")
example["details"]["metadata"]["bulk_published"] = true
refute present_example(example).metadata[:first_published]
@@ -129,7 +129,7 @@ class PresentedSpecialistDocument < SpecialistDocumentTestCase
class PresentedSpecialistDocumentWithFinderFacets < SpecialistDocumentTestCase
def example_with_finder_facets(facets = [], values = {})
- example = schema_item('aaib-reports')
+ example = schema_item("aaib-reports")
example_finder = {
"class" => "govuk-link",
"base_path" => "/finder-base-path",
@@ -137,15 +137,15 @@ def example_with_finder_facets(facets = [], values = {})
"details" => {
"document_noun" => "case",
"filter" => {
- "document_type" => "cma_case"
+ "document_type" => "cma_case",
},
"format_name" => "Competition and Markets Authority case",
"facets" => facets,
},
}
- example['details']['metadata'] = values
- example['links']['finder'] = [example_finder]
+ example["details"]["metadata"] = values
+ example["links"]["finder"] = [example_finder]
example
end
@@ -154,11 +154,11 @@ def example_facet(overrides = {})
"name" => "Facet name",
"key" => "facet-key",
"type" => "text",
- "filterable" => false
+ "filterable" => false,
}.merge(overrides)
end
- test 'includes non-filterable facet as text in metadata' do
+ test "includes non-filterable facet as text in metadata" do
values = { "facet-key" => "document-value" }
example = example_with_finder_facets([example_facet], values)
@@ -166,14 +166,14 @@ def example_facet(overrides = {})
assert_equal "document-value", presented.important_metadata["Facet name"]
end
- test 'includes friendly label for facet value in metadata' do
+ test "includes friendly label for facet value in metadata" do
overrides = {
"allowed_values" => [
{
"label" => "Document value from label",
- "value" => "document-value"
- }
- ]
+ "value" => "document-value",
+ },
+ ],
}
values = { "facet-key" => "document-value" }
@@ -183,29 +183,29 @@ def example_facet(overrides = {})
assert_equal "Document value from label", presented.important_metadata["Facet name"]
end
- test 'falls back to provided value if value not found in allowed list' do
+ test "falls back to provided value if value not found in allowed list" do
overrides = {
"allowed_values" => [
{
"label" => "Document value from label",
- "value" => "document-value"
- }
- ]
+ "value" => "document-value",
+ },
+ ],
}
values = { "facet-key" => "not-an-allowed-value" }
example = example_with_finder_facets([example_facet(overrides)], values)
GovukError.expects(:notify).once.with(
- 'Facet value not in list of allowed values',
- extra: { error_message: "Facet value 'not-an-allowed-value' not an allowed value for facet 'Facet name' on /aaib-reports/aaib-investigation-to-rotorsport-uk-calidus-g-pcpc content item" }
+ "Facet value not in list of allowed values",
+ extra: { error_message: "Facet value 'not-an-allowed-value' not an allowed value for facet 'Facet name' on /aaib-reports/aaib-investigation-to-rotorsport-uk-calidus-g-pcpc content item" },
)
presented = present_example(example)
assert_equal "not-an-allowed-value", presented.important_metadata["Facet name"]
end
- test 'ignores facets in metadata if not a valid finder facet' do
+ test "ignores facets in metadata if not a valid finder facet" do
values = { "random-invalid-facet" => "something-odd" }
example = example_with_finder_facets([example_facet], values)
@@ -213,7 +213,7 @@ def example_facet(overrides = {})
assert_empty presented.metadata[:other]
end
- test 'ignores facets if valid key but set to an empty string' do
+ test "ignores facets if valid key but set to an empty string" do
example = example_with_finder_facets([
{
"name" => "Facet name",
@@ -224,26 +224,26 @@ def example_facet(overrides = {})
"name" => "Date facet",
"key" => "date-facet",
"type" => "date",
- }
+ },
],
- "facet-key" => "",
- "date-facet" => "")
+ "facet-key" => "",
+ "date-facet" => "")
assert_empty present_example(example).metadata[:other]
end
- test 'passes array of multiple values to metadata' do
+ test "passes array of multiple values to metadata" do
overrides = {
"allowed_values" => [
{
"label" => "One",
- "value" => "one"
+ "value" => "one",
},
{
"label" => "Two",
- "value" => "two"
- }
- ]
+ "value" => "two",
+ },
+ ],
}
values = { "facet-key" => %w{one two} }
@@ -253,15 +253,15 @@ def example_facet(overrides = {})
assert_equal %w{One Two}, presented.important_metadata["Facet name"]
end
- test 'creates links for filterable friendly values' do
+ test "creates links for filterable friendly values" do
overrides = {
"filterable" => true,
"allowed_values" => [
{
"label" => "Something",
- "value" => "something"
- }
- ]
+ "value" => "something",
+ },
+ ],
}
values = { "facet-key" => "something" }
@@ -272,7 +272,7 @@ def example_facet(overrides = {})
assert_equal expected_link, presented.important_metadata["Facet name"]
end
- test 'includes friendly dates for date facets in metadata' do
+ test "includes friendly dates for date facets in metadata" do
overrides = { "type" => "date" }
values = { "facet-key" => "2010-01-01" }
example = example_with_finder_facets([example_facet(overrides)], values)
@@ -281,7 +281,7 @@ def example_facet(overrides = {})
assert_equal "1 January 2010", presented_metadata["Facet name"]
end
- test 'puts date facets together and before text facets' do
+ test "puts date facets together and before text facets" do
example = example_with_finder_facets([
{
"name" => "Facet name",
@@ -302,57 +302,57 @@ def example_facet(overrides = {})
"name" => "More text",
"key" => "more-text",
"type" => "text",
- }
+ },
],
- "facet-key" => "Text",
- "first-date-facet" => "2010-01-01",
- "second-date-facet" => "2010-02-03",
- "more-text" => "More text")
+ "facet-key" => "Text",
+ "first-date-facet" => "2010-01-01",
+ "second-date-facet" => "2010-02-03",
+ "more-text" => "More text")
expected_order = ["First date facet", "Second date facet", "Facet name", "More text"]
assert_equal expected_order, present_example(example).important_metadata.keys
end
- test 'sends an error notification when there is no finder' do
- example = schema_item('aaib-reports')
- example['links']['finder'] = []
+ test "sends an error notification when there is no finder" do
+ example = schema_item("aaib-reports")
+ example["links"]["finder"] = []
GovukError.expects(:notify).with(
- 'Finder not found',
- extra: { error_message: 'Finder not found in /aaib-reports/aaib-investigation-to-rotorsport-uk-calidus-g-pcpc content item' }
+ "Finder not found",
+ extra: { error_message: "Finder not found in /aaib-reports/aaib-investigation-to-rotorsport-uk-calidus-g-pcpc content item" },
)
present_example(example).important_metadata
end
- test 'omits first_published_at facet values from `other` section of component parameters to avoid duplicates' do
+ test "omits first_published_at facet values from `other` section of component parameters to avoid duplicates" do
facets = [
{
"name" => "Published",
"key" => "first_published_at",
"type" => "date",
- }
+ },
]
example = example_with_finder_facets(facets, "first_published_at" => "2010-01-01")
presented = present_example(example)
- refute presented.metadata[:other]['Published']
+ refute presented.metadata[:other]["Published"]
end
- test 'uses first published date in facets as canonical publish date if provided' do
+ test "uses first published date in facets as canonical publish date if provided" do
facets = [
{
"name" => "Published",
"key" => "first_published_at",
"type" => "date",
- }
+ },
]
example = example_with_finder_facets(facets, "first_published_at" => "2010-01-01")
example["details"]["change_history"] = [
{
"note" => "A date in the change history",
- "public_timestamp" => "2002-02-02"
+ "public_timestamp" => "2002-02-02",
},
]
diff --git a/test/presenters/speech_presenter_test.rb b/test/presenters/speech_presenter_test.rb
index d94ef1604..00adbb8ed 100644
--- a/test/presenters/speech_presenter_test.rb
+++ b/test/presenters/speech_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class SpeechPresenterTest
class SpeechTestCase < PresenterTestCase
@@ -8,89 +8,89 @@ def schema_name
end
class PresentedSpeech < SpeechTestCase
- test 'presents the schema name' do
- assert_equal schema_item['schema_name'], presented_item.schema_name
+ test "presents the schema name" do
+ assert_equal schema_item["schema_name"], presented_item.schema_name
end
- test '#published returns a formatted date of the day the content item became public' do
+ test "#published returns a formatted date of the day the content item became public" do
assert_equal "8 March 2016", presented_item.published
end
- test 'presents a description' do
- assert_equal schema_item['description'], presented_item.description
+ test "presents a description" do
+ assert_equal schema_item["description"], presented_item.description
end
- test 'presents a speech location' do
- assert_equal schema_item['details']['location'], presented_item.important_metadata["Location"]
+ test "presents a speech location" do
+ assert_equal schema_item["details"]["location"], presented_item.important_metadata["Location"]
end
- test 'presents how speech was delivered' do
- assert_equal 'Delivered on', presented_item.delivery_type
+ test "presents how speech was delivered" do
+ assert_equal "Delivered on", presented_item.delivery_type
end
- test 'presents a delivered on date with speech type explanation for the metadata component' do
+ test "presents a delivered on date with speech type explanation for the metadata component" do
assert_equal ' (Original script, may differ from delivered version)', presented_item.delivered_on_metadata
end
- test 'presents the body' do
- expected_body = schema_item['details']['body']
+ test "presents the body" do
+ expected_body = schema_item["details"]["body"]
assert_equal expected_body, presented_item.body
end
- test 'from includes speaker' do
+ test "from includes speaker" do
assert presented_item.from.include?("The Rt Hon Andrea Leadsom MP")
end
end
class TranscriptPresentedSpeech < SpeechTestCase
def example_schema_name
- 'speech-transcript'
+ "speech-transcript"
end
- test 'presents a delivered on date with speech type explanation for the metadata component' do
+ test "presents a delivered on date with speech type explanation for the metadata component" do
assert_equal ' (Original script, may differ from delivered version)', presented_item.delivered_on_metadata
end
end
class WrittenStatementParliamentPresentedSpeech < SpeechTestCase
def example_schema_name
- 'speech-written-statement-parliament'
+ "speech-written-statement-parliament"
end
- test 'presents the speech as being delivered' do
- assert_equal 'Delivered on', presented_item(example_schema_name).delivery_type
+ test "presents the speech as being delivered" do
+ assert_equal "Delivered on", presented_item(example_schema_name).delivery_type
end
- test 'presents a delivered on date without an explanation' do
+ test "presents a delivered on date without an explanation" do
assert_equal '', presented_item(example_schema_name).delivered_on_metadata
end
end
class AuthoredArticlePresentedSpeech < SpeechTestCase
def example_schema_name
- 'speech-authored-article'
+ "speech-authored-article"
end
- test 'presents the speech as being written' do
- assert_equal 'Written on', presented_item(example_schema_name).delivery_type
+ test "presents the speech as being written" do
+ assert_equal "Written on", presented_item(example_schema_name).delivery_type
end
- test 'presents a delivered on date without an explanation' do
+ test "presents a delivered on date without an explanation" do
assert_equal '', presented_item(example_schema_name).delivered_on_metadata
end
end
class SpeakerWithoutProfilePresentedSpeech < SpeechTestCase
def example_schema_name
- 'speech-speaker-without-profile'
+ "speech-speaker-without-profile"
end
- test 'includes speaker without profile in from_with_speaker' do
+ test "includes speaker without profile in from_with_speaker" do
assert_equal [
"Prime Minister's Office, 10 Downing Street",
"Cabinet Office",
- "Her Majesty the Queen"
+ "Her Majesty the Queen",
], presented_item(example_schema_name).from
end
end
diff --git a/test/presenters/statistical_data_set_presenter_test.rb b/test/presenters/statistical_data_set_presenter_test.rb
index 4da422002..ef30a7cf3 100644
--- a/test/presenters/statistical_data_set_presenter_test.rb
+++ b/test/presenters/statistical_data_set_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class StatisticalDataSetPresenterTest
class StatisticalDataSetTestCase < PresenterTestCase
@@ -8,25 +8,25 @@ def schema_name
end
class PresentedStatisticalDataSet < StatisticalDataSetTestCase
- test 'presents the schema name' do
- assert_equal schema_item['schema_name'], presented_item.schema_name
+ test "presents the schema name" do
+ assert_equal schema_item["schema_name"], presented_item.schema_name
end
- test 'presents a list of contents extracted from headings in the body' do
+ test "presents a list of contents extracted from headings in the body" do
expected_contents_item = { text: "Olympics", id: "olympics", href: "#olympics" }
assert_equal expected_contents_item, presented_item.contents[0]
end
- test '#published returns a formatted date of the day the content item became public' do
+ test "#published returns a formatted date of the day the content item became public" do
assert_equal "13 December 2012", presented_item.published
end
- test 'presents a description' do
+ test "presents a description" do
assert_equal schema_item["description"], presented_item.description
end
- test 'presents the body' do
- expected_body = schema_item['details']['body']
+ test "presents the body" do
+ expected_body = schema_item["details"]["body"]
assert_equal expected_body, presented_item.body
end
@@ -45,15 +45,15 @@ def presented
presented_item(example_schema_name)
end
- test 'presents the withdrawn notice explanation' do
+ test "presents the withdrawn notice explanation" do
assert_equal expected["withdrawn_notice"]["explanation"], presented.withdrawal_notice_component[:description_govspeak]
end
- test 'presents the withdrawn notification time' do
+ test "presents the withdrawn notification time" do
expected_time = expected["withdrawn_notice"]["withdrawn_at"]
expected_date_as_string = I18n.l(
Date.parse(expected_time),
- format: "%-d %B %Y"
+ format: "%-d %B %Y",
)
expected_withdrawn_time_html = ""
@@ -74,7 +74,7 @@ def presented
presented_item(example_schema_name)
end
- test 'presents the political fields' do
+ test "presents the political fields" do
assert_equal expected["details"]["political"], presented.historically_political?
assert_equal expected["details"]["government"]["title"], presented.publishing_government
end
diff --git a/test/presenters/statistics_announcement_presenter_test.rb b/test/presenters/statistics_announcement_presenter_test.rb
index 9a66496c3..3c326f704 100644
--- a/test/presenters/statistics_announcement_presenter_test.rb
+++ b/test/presenters/statistics_announcement_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class StatisticsAnnouncementPresenterTest < PresenterTestCase
include ActionView::Helpers::UrlHelper
@@ -7,36 +7,36 @@ def schema_name
"statistics_announcement"
end
- test 'presents from as links to organisations' do
+ test "presents from as links to organisations" do
links = [
- link_to('NHS England', '/government/organisations/nhs-commissioning-board', class: "govuk-link")
+ link_to("NHS England", "/government/organisations/nhs-commissioning-board", class: "govuk-link"),
]
assert_equal links, statistics_announcement.from
end
- test 'presents release_date' do
- assert_equal '20 January 2016 9:30am', statistics_announcement.release_date
+ test "presents release_date" do
+ assert_equal "20 January 2016 9:30am", statistics_announcement.release_date
end
- test 'presents previous_release_date' do
- assert_equal '19 January 2016 9:30am', statistics_announcement_date_changed.previous_release_date
+ test "presents previous_release_date" do
+ assert_equal "19 January 2016 9:30am", statistics_announcement_date_changed.previous_release_date
end
- test 'presents release_date_and_status when confirmed' do
- assert_equal '20 January 2016 9:30am (confirmed)', statistics_announcement.release_date_and_status
+ test "presents release_date_and_status when confirmed" do
+ assert_equal "20 January 2016 9:30am (confirmed)", statistics_announcement.release_date_and_status
end
- test 'presents release_date_and_status when provisional' do
- assert_equal 'January 2016 (provisional)', statistics_announcement_provisional.release_date_and_status
+ test "presents release_date_and_status when provisional" do
+ assert_equal "January 2016 (provisional)", statistics_announcement_provisional.release_date_and_status
end
- test 'presents release_date_and_status when cancelled' do
- assert_equal '20 January 2016 9:30am', statistics_announcement_cancelled.release_date_and_status
+ test "presents release_date_and_status when cancelled" do
+ assert_equal "20 January 2016 9:30am", statistics_announcement_cancelled.release_date_and_status
end
test "present important metadata when confirmed" do
metadata = {
- "Release date" => "20 January 2016 9:30am (confirmed)"
+ "Release date" => "20 January 2016 9:30am (confirmed)",
}
assert_equal metadata, statistics_announcement.important_metadata
end
@@ -44,7 +44,7 @@ def schema_name
test "present important metadata when cancelled" do
metadata = {
"Proposed release" => "20 January 2016 9:30am",
- "Cancellation date" => "17 January 2016 2:19pm"
+ "Cancellation date" => "17 January 2016 2:19pm",
}
assert_equal metadata, statistics_announcement_cancelled.important_metadata
end
@@ -54,41 +54,41 @@ def schema_name
assert_equal "Official Statistics", item.cancellation_reason
end
- test 'knows if an item is a national statistic' do
+ test "knows if an item is a national statistic" do
refute statistics_announcement.national_statistics?
assert statistics_announcement_national.national_statistics?
end
- test 'knows if the release date has changed' do
+ test "knows if the release date has changed" do
assert statistics_announcement_date_changed.release_date_changed?
refute statistics_announcement_national.release_date_changed?
end
- test 'an announcement is forthcoming if it is not cancelled' do
+ test "an announcement is forthcoming if it is not cancelled" do
assert statistics_announcement.forthcoming_publication?
end
- test 'a cancelled announcement takes precedence over a forthcoming announcement' do
+ test "a cancelled announcement takes precedence over a forthcoming announcement" do
refute statistics_announcement_cancelled.forthcoming_publication?
end
def statistics_announcement_cancelled
- presented_item('cancelled_official_statistics')
+ presented_item("cancelled_official_statistics")
end
def statistics_announcement_provisional
- presented_item('national_statistics')
+ presented_item("national_statistics")
end
def statistics_announcement_national
- presented_item('national_statistics')
+ presented_item("national_statistics")
end
def statistics_announcement_date_changed
- presented_item('release_date_changed')
+ presented_item("release_date_changed")
end
def statistics_announcement
- presented_item('official_statistics')
+ presented_item("official_statistics")
end
end
diff --git a/test/presenters/take_part_presenter_test.rb b/test/presenters/take_part_presenter_test.rb
index 856515b74..61204af38 100644
--- a/test/presenters/take_part_presenter_test.rb
+++ b/test/presenters/take_part_presenter_test.rb
@@ -1,15 +1,15 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class TakePartPresenterTest < PresenterTestCase
def schema_name
"take_part"
end
- test 'presents the basic details of a content item' do
- assert_equal schema_item['description'], presented_item.description
- assert_equal schema_item['schema_name'], presented_item.schema_name
- assert_equal schema_item['locale'], presented_item.locale
- assert_equal schema_item['title'], presented_item.title
- assert_equal schema_item['details']['body'], presented_item.body
+ test "presents the basic details of a content item" do
+ assert_equal schema_item["description"], presented_item.description
+ assert_equal schema_item["schema_name"], presented_item.schema_name
+ assert_equal schema_item["locale"], presented_item.locale
+ assert_equal schema_item["title"], presented_item.title
+ assert_equal schema_item["details"]["body"], presented_item.body
end
end
diff --git a/test/presenters/topical_event_about_page_presenter_test.rb b/test/presenters/topical_event_about_page_presenter_test.rb
index 575d79ae9..ff5d9cade 100644
--- a/test/presenters/topical_event_about_page_presenter_test.rb
+++ b/test/presenters/topical_event_about_page_presenter_test.rb
@@ -1,18 +1,18 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class TopicalEventAboutPagePresenterTest < PresenterTestCase
def schema_name
"topical_event_about_page"
end
- test 'presents the basic details of a content item' do
- assert_equal schema_item['description'], presented_item.description
- assert_equal schema_item['schema_name'], presented_item.schema_name
- assert_equal schema_item['title'], presented_item.title
- assert_equal schema_item['details']['body'], presented_item.body
+ test "presents the basic details of a content item" do
+ assert_equal schema_item["description"], presented_item.description
+ assert_equal schema_item["schema_name"], presented_item.schema_name
+ assert_equal schema_item["title"], presented_item.title
+ assert_equal schema_item["details"]["body"], presented_item.body
end
- test 'presents a list of contents extracted from headings in the body' do
+ test "presents a list of contents extracted from headings in the body" do
assert_equal [
{ text: "Response in the UK", id: "response-in-the-uk", href: "#response-in-the-uk" },
{ text: "Response in Africa", id: "response-in-africa", href: "#response-in-africa" },
@@ -23,7 +23,7 @@ def schema_name
], presented_item.contents
end
- test 'presents no contents when no headings in the body' do
- assert_equal [], presented_item('slim').contents
+ test "presents no contents when no headings in the body" do
+ assert_equal [], presented_item("slim").contents
end
end
diff --git a/test/presenters/travel_advice_presenter_test.rb b/test/presenters/travel_advice_presenter_test.rb
index ea69c51ed..ef5aa2559 100644
--- a/test/presenters/travel_advice_presenter_test.rb
+++ b/test/presenters/travel_advice_presenter_test.rb
@@ -1,4 +1,4 @@
-require 'presenter_test_helper'
+require "presenter_test_helper"
class TravelAdvicePresenterTest
class PresentedTravelAdvice < PresenterTestCase
@@ -6,7 +6,7 @@ def schema_name
"travel_advice"
end
- test 'has parts' do
+ test "has parts" do
assert presented_item("full-country").is_a?(ContentItem::Parts)
end
@@ -17,33 +17,33 @@ def schema_name
test "part slug set to last segment of requested content item path when content item has parts" do
example = schema_item("full-country")
- first_part = example['details']['parts'].first
- presented = presented_item("full-country", first_part['slug'])
+ first_part = example["details"]["parts"].first
+ presented = presented_item("full-country", first_part["slug"])
assert presented.requesting_a_part?
- assert_equal presented.part_slug, first_part['slug']
+ assert_equal presented.part_slug, first_part["slug"]
assert presented.has_valid_part?
end
test "knows when an invalid part has been requested" do
- presented = presented_item("full-country", 'not-a-valid-part')
+ presented = presented_item("full-country", "not-a-valid-part")
assert presented.requesting_a_part?
- assert_equal presented.part_slug, 'not-a-valid-part'
+ assert_equal presented.part_slug, "not-a-valid-part"
refute presented.has_valid_part?
end
test "presents unique titles for each part" do
example = schema_item("full-country")
presented = presented_item("full-country")
- assert_equal example['title'], presented.page_title
+ assert_equal example["title"], presented.page_title
- first_part = example['details']['parts'].first
- presented_part = presented_item("full-country", first_part['slug'])
+ first_part = example["details"]["parts"].first
+ presented_part = presented_item("full-country", first_part["slug"])
assert_equal "#{first_part['title']} - #{example['title']}", presented_part.page_title
end
- test 'presents withdrawn in the title for withdrawn content' do
+ test "presents withdrawn in the title for withdrawn content" do
presented_item = presented_item("full-country", nil, "withdrawn_notice" => { "explanation": "Withdrawn", "withdrawn_at": "2014-08-22T10:29:02+01:00" })
assert_equal "[Withdrawn] Albania travel advice", presented_item.page_title
end
@@ -53,8 +53,8 @@ def schema_name
presented = presented_item("full-country")
assert presented.is_summary?
- assert_equal 'Summary', presented.current_part_title
- assert_equal example['details']['summary'], presented.current_part_body
+ assert_equal "Summary", presented.current_part_title
+ assert_equal example["details"]["summary"], presented.current_part_body
end
test "presents the current part when a part slug is provided" do
@@ -64,12 +64,12 @@ def schema_name
refute presented.is_summary?
assert presented.has_valid_part?
- assert_equal first_part['title'], presented.current_part_title
- assert_equal first_part['body'], presented.current_part_body
+ assert_equal first_part["title"], presented.current_part_title
+ assert_equal first_part["body"], presented.current_part_body
end
test "marks parts not in the content item as invalid" do
- example_part_slugs = schema_item("full-country")["details"]["parts"].map { |part| part['slug'] }
+ example_part_slugs = schema_item("full-country")["details"]["parts"].map { |part| part["slug"] }
presented = presented_item("full-country", "not-a-valid-part")
refute example_part_slugs.include?("not-a-valid-part")
@@ -78,7 +78,7 @@ def schema_name
test "the summary is included as the first navigation item" do
first_nav_item = presented_item("full-country").parts_navigation.first.first
- assert_equal 'Summary', first_nav_item
+ assert_equal "Summary", first_nav_item
end
test "navigation items are presented as trackable links unless they are the current part" do
@@ -97,7 +97,7 @@ def schema_name
"data-track-label=\"/foreign-travel-advice/albania\" "\
"data-track-options=\"{"dimension29":"Summary"}\" "\
"href=\"/foreign-travel-advice/albania\">Summary"
- assert_equal current_part_nav_item, current_part['title']
+ assert_equal current_part_nav_item, current_part["title"]
assert_equal another_part_nav_item,
"XML'
+ example["details"]["change_description"] = "Test XML"
assert_equal "