From 6585d3e9236281533d0de1cc320a0c4a93a88b5b Mon Sep 17 00:00:00 2001 From: Elliot Crosby-McCullough Date: Fri, 25 Nov 2022 10:31:17 +0000 Subject: [PATCH 1/4] Fix UK_AND_CI_POSTCODE_PREFIX_COUNTRIES schema --- lib/dfe/reference_data/countries_and_territories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dfe/reference_data/countries_and_territories.rb b/lib/dfe/reference_data/countries_and_territories.rb index ee1bc9db..31f8a38b 100644 --- a/lib/dfe/reference_data/countries_and_territories.rb +++ b/lib/dfe/reference_data/countries_and_territories.rb @@ -307,7 +307,7 @@ module CountriesAndTerritories }, { id: :string, - prefixes: { schema: :string, kind: :array } + prefixes: { kind: :array, element_schema: :string } } ) end From 27d826ad80f1cfe30c0b997e249443e8683ae654 Mon Sep 17 00:00:00 2001 From: Elliot Crosby-McCullough Date: Fri, 25 Nov 2022 10:31:31 +0000 Subject: [PATCH 2/4] Add missing test for UK_AND_CI_POSTCODE_PREFIX_COUNTRIES --- .../countries_and_territories_spec.rb | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/spec/lib/dfe/reference_data/countries_and_territories_spec.rb b/spec/lib/dfe/reference_data/countries_and_territories_spec.rb index 9a45adc7..4ea4fa40 100644 --- a/spec/lib/dfe/reference_data/countries_and_territories_spec.rb +++ b/spec/lib/dfe/reference_data/countries_and_territories_spec.rb @@ -1,11 +1,22 @@ require 'dfe/reference_data/countries_and_territories' -RSpec.describe DfE::ReferenceData::CountriesAndTerritories::COUNTRIES_AND_TERRITORIES do - it_should_behave_like 'a list of valid records' - it_should_behave_like 'a valid autocomplete-capable list' +RSpec.describe DfE::ReferenceData::CountriesAndTerritories do + describe described_class::COUNTRIES_AND_TERRITORIES do + it_should_behave_like 'a list of valid records' + it_should_behave_like 'a valid autocomplete-capable list' - it 'contains mappings from ISO codes to country names' do - expect(described_class.one('AW').name).to eq('Aruba') - expect(described_class.one('UM-81').name).to eq('Baker Island') + it 'contains mappings from ISO codes to country names' do + expect(described_class.one('AW').name).to eq('Aruba') + expect(described_class.one('UM-81').name).to eq('Baker Island') + end + end + + describe described_class::UK_AND_CI_POSTCODE_PREFIX_COUNTRIES do + it_should_behave_like 'a list of valid records' + + it 'contains mappings from UK and Channel Island country/territory names to lists of postcode prefixes' do + expect(described_class.one('Wales').prefixes).to eq(%w[CF SA]) + expect(described_class.one('Jersey').prefixes).to eq(%w[JE]) + end end end From 93c8589a03be603924497edb59ba77709876b5ee Mon Sep 17 00:00:00 2001 From: Elliot Crosby-McCullough Date: Fri, 25 Nov 2022 10:32:14 +0000 Subject: [PATCH 3/4] Add docs for countries/territories and HESA domiciles --- docs/lists_countries_and_territories.md | 52 +++++++++++++++++ docs/lists_hesa_domiciles.md | 75 +++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 docs/lists_countries_and_territories.md create mode 100644 docs/lists_hesa_domiciles.md diff --git a/docs/lists_countries_and_territories.md b/docs/lists_countries_and_territories.md new file mode 100644 index 00000000..253695c7 --- /dev/null +++ b/docs/lists_countries_and_territories.md @@ -0,0 +1,52 @@ +## Countries and territories + +- A mapping of ISO country/territory codes to country/territory names. +- Postcode prefixes for the UK and Channel Islands grouped by country/territory. + +### `DfE::ReferenceData::CountriesAndTerritories::COUNTRIES_AND_TERRITORIES` + +```ruby +require 'dfe/reference_data/countries_and_territories' +``` + +A mapping of ISO country/territory codes to country/territory names. + +Owner: Apply team. + +Users: Apply team. + +Source: +https://github.com/DFE-Digital/apply-for-teacher-training/blob/78c9421d8582f63cfdec564b5c0677bfd787552c/config/initializers/countries_and_territories.rb +https://github.com/alphagov/govuk-country-and-territory-autocomplete/blob/5214c44/dist/location-autocomplete-canonical-list.json + +Quality: Manually updated on an ad-hoc basis. Please submit a pull request if inaccuracies or omissions are found. + +This list is [autocomplete compatible](autocomplete_compatability.md). + +| Field | Type | Purpose | +| ------ | ------ | --------------------------------------------------- | +| `id` | string | The country or territory's ISO code | +| `name` | string | The human-readable name of the country or territory | + +### `DfE::ReferenceData::CountriesAndTerritories::UK_AND_CI_POSTCODE_PREFIX_COUNTRIES` + +```ruby +require 'dfe/reference_data/countries_and_territories' +``` + +Postcode prefixes for the UK and Channel Islands grouped by country/territory. + +Owner: Apply team. + +Users: Apply team. + +Source: https://github.com/DFE-Digital/apply-for-teacher-training/blob/78c9421d8582f63cfdec564b5c0677bfd787552c/app/lib/domicile_resolver.rb#L47-L59 + +Quality: Manually updated on an ad-hoc basis. Please submit a pull request if inaccuracies or omissions are found. + +This list is NOT [autocomplete compatible](autocomplete_compatability.md). + +| Field | Type | Purpose | +| ---------- | ------------ | ------------------------------------------ | +| `id` | string | The human readable country/territory name | +| `prefixes` | string array | A list of postcode prefixes (letters only) | diff --git a/docs/lists_hesa_domiciles.md b/docs/lists_hesa_domiciles.md new file mode 100644 index 00000000..eb640616 --- /dev/null +++ b/docs/lists_hesa_domiciles.md @@ -0,0 +1,75 @@ +## HESA domicile data + +- HESA-specific overrides for the countries and territories list. +- HESA-specific overrides for ISO country/territory codes. +- HESA codes for UK and Channel Islands countries/territories. + +### `DfE::ReferenceData::HESA::Domiciles::COUNTRIES_AND_TERRITORIES` + +```ruby +require 'dfe/reference_data/hesa/domiciles' +``` + +HESA-specific overrides for the countries and territories list. Delegates to `DfE::ReferenceData::CountriesAndTerritories::COUNTRIES_AND_TERRITORIES`. + +Owner: Apply team. + +Users: Apply team. + +Source: https://github.com/DFE-Digital/apply-for-teacher-training/blob/78c9421d8582f63cfdec564b5c0677bfd787552c/app/lib/domicile_resolver.rb#L29-L44 + +Quality: Manually updated on an ad-hoc basis. Please submit a pull request if inaccuracies or omissions are found. + +This list is NOT [autocomplete compatible](autocomplete_compatability.md) as it +contains a `nil` value. + +| Field | Type | Purpose | +| ------ | ----------- | --------------------------------------------------- | +| `id` | string | The country or territory's ISO code | +| `name` | string/null | The human-readable name of the country or territory | + +### `DfE::ReferenceData::HESA::Domiciles::SPECIAL_ISO_CODES` + +```ruby +require 'dfe/reference_data/hesa/domiciles' +``` + +HESA-specific overrides for ISO country/territory codes. + +Owner: Apply team. + +Users: Apply team. + +Source: https://github.com/DFE-Digital/apply-for-teacher-training/blob/78c9421d8582f63cfdec564b5c0677bfd787552c/app/lib/domicile_resolver.rb#L3-L12 + +Quality: Manually updated on an ad-hoc basis. Please submit a pull request if inaccuracies or omissions are found. + +This list is NOT [autocomplete compatible](autocomplete_compatability.md). + +| Field | Type | Purpose | +| ------ | ----------- | ------------------------- | +| `id` | string/null | The normal ISO code | +| `code` | string | The special HESA ISO code | + +### `DfE::ReferenceData::HESA::Domiciles::CODES_FOR_UK_AND_CI` + +```ruby +require 'dfe/reference_data/hesa/domiciles' +``` + +HESA codes for UK and Channel Islands countries/territories. + +Owner: Apply team. + +Users: Apply team. + +Source: https://github.com/DFE-Digital/apply-for-teacher-training/blob/78c9421d8582f63cfdec564b5c0677bfd787552c/app/lib/domicile_resolver.rb#L14-L27 + +Quality: Manually updated on an ad-hoc basis. Please submit a pull request if inaccuracies or omissions are found. + +This list is NOT [autocomplete compatible](autocomplete_compatability.md). + +| Field | Type | Purpose | +| ------ | ----------- | ------------------------------------- | +| `id` | string/null | Human-readable country/territory name | +| `code` | string | HESA code | From 4b76c8234a7be72e351bd20937a3cd3c12c5feb6 Mon Sep 17 00:00:00 2001 From: lint-bot Date: Fri, 25 Nov 2022 10:33:22 +0000 Subject: [PATCH 4/4] Code style fixes --- spec/lib/dfe/reference_data/countries_and_territories_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/dfe/reference_data/countries_and_territories_spec.rb b/spec/lib/dfe/reference_data/countries_and_territories_spec.rb index 4ea4fa40..7c5b452c 100644 --- a/spec/lib/dfe/reference_data/countries_and_territories_spec.rb +++ b/spec/lib/dfe/reference_data/countries_and_territories_spec.rb @@ -15,8 +15,8 @@ it_should_behave_like 'a list of valid records' it 'contains mappings from UK and Channel Island country/territory names to lists of postcode prefixes' do - expect(described_class.one('Wales').prefixes).to eq(%w[CF SA]) - expect(described_class.one('Jersey').prefixes).to eq(%w[JE]) + expect(described_class.one('Wales').prefixes).to eq(['CF', 'SA']) + expect(described_class.one('Jersey').prefixes).to eq(['JE']) end end end