<NME> marriage_abroad_data_query.rb
<BEF> module SmartAnswer::Calculators
  class MarriageAbroadDataQuery
    BRITISH_OVERSEAS_TERRITORIES = %w[
      anguilla
      bermuda
      british-antarctic-territory
      british-indian-ocean-territory
      british-virgin-islands
      cayman-islands
      falkland-islands
      gibraltar
      montserrat

    DUTCH_CARIBBEAN_ISLANDS = %w(aruba bonaire-st-eustatius-saba curacao st-maarten)

    NON_COMMONWEALTH_COUNTRIES = %w(afghanistan albania algeria american-samoa andorra angola anguilla argentina armenia aruba austria azerbaijan bahrain belarus belgium benin bermuda bhutan bolivia bonaire-st-eustatius-saba bosnia-and-herzegovina brazil british-indian-ocean-territory british-virgin-islands bulgaria burkina-faso burma burundi cambodia cape-verde cayman-islands central-african-republic chad chile china colombia comoros congo democratic-republic-of-congo costa-rica cote-d-ivoire croatia cuba curacao czech-republic denmark djibouti dominican-republic ecuador egypt el-salvador equatorial-guinea eritrea estonia ethiopia falkland-islands fiji finland france french-guiana french-polynesia gabon georgia germany gibraltar greece guadeloupe guatemala guinea guinea-bissau haiti honduras hong-kong hungary iceland indonesia iran iraq ireland israel italy japan jordan kazakhstan south-korea kosovo kuwait kyrgyzstan laos latvia lebanon liberia libya liechtenstein lithuania luxembourg macao macedonia madagascar mali marshall-islands martinique mauritania mayotte mexico micronesia moldova monaco mongolia montenegro montserrat morocco nepal netherlands new-caledonia nicaragua niger north-korea norway oman palau panama paraguay peru philippines pitcairn-island poland portugal qatar reunion romania russia rwanda san-marino sao-tome-and-principe saudi-arabia senegal serbia slovakia slovenia somalia south-georgia-and-south-sandwich-islands south-sudan spain st-helena-ascension-and-tristan-da-cunha st-maarten st-pierre-and-miquelon sudan suriname sweden switzerland syria taiwan tajikistan thailand timor-leste togo tunisia turkmenistan turks-and-caicos-islands ukraine united-arab-emirates usa uruguay uzbekistan venezuela wallis-and-futuna western-sahara vietnam yemen zimbabwe)

    OS_CONSULAR_CNI_COUNTRIES = %w(albania algeria angola armenia austria azerbaijan bahrain belarus belgium bolivia bosnia-and-herzegovina brazil bulgaria chile croatia cuba denmark dominican-republic el-salvador estonia ethiopia georgia germany greece guatemala honduras hungary iceland indonesia italy japan jordan kazakhstan kuwait kyrgyzstan latvia libya lithuania luxembourg macedonia moldova montenegro netherlands nepal norway oman panama poland romania russia serbia slovenia spain sudan sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)

    OS_NO_CONSULAR_CNI_COUNTRIES = %w(argentina burundi czech-republic democratic-republic-of-congo mexico senegal slovakia taiwan usa uruguay)

    OS_NO_MARRIAGE_CONSULAR_SERVICES = %w(afghanistan american-samoa andorra aruba benin bhutan bonaire-st-eustatius-saba burkina-faso burundi cape-verde central-african-republic chad comoros congo costa-rica cote-d-ivoire curacao djibouti equatorial-guinea eritrea gabon guinea guinea-bissau haiti hong-kong iraq israel kosovo laos liberia liechtenstein macao madagascar mali marshall-islands mauritania micronesia monaco nicaragua niger palau paraguay rwanda san-marino sao-tome-and-principe south-sudan st-maarten suriname timor-leste togo western-sahara)

      mayotte
      new-caledonia
      reunion
      st-pierre-and-miquelon
      wallis-and-futuna
    ].freeze

    CEREMONY_COUNTRIES_OFFERING_PACS = %w[
      monaco

    CP_CONSULAR_COUNTRIES = %w(bulgaria cambodia croatia cyprus guatemala japan latvia moldova panama peru philippines venezuela vietnam)

    COUNTRIES_WITHOUT_CONSULAR_FACILITIES = %w(aruba slovakia curacao bonaire-st-eustatius-saba st-maarten taiwan czech-republic argentina cote-d-ivoire burundi)

    SS_MARRIAGE_COUNTRIES = %w(australia azerbaijan bolivia chile china colombia dominican-republic estonia germany kosovo latvia mongolia montenegro nicaragua russia san-marino hungary serbia)

    ].freeze

    COUNTRIES_WITHOUT_CONSULAR_FACILITIES = %w[
      argentina
      aruba
      bonaire-st-eustatius-saba
      burundi
      cote-d-ivoire
      curacao
      czech-republic
      saint-barthelemy
      slovakia
      st-maarten
      st-martin
      taiwan

    OS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES = %(jordan oman qatar united-arab-emirates yemen)

    def ss_21_days_residency_required_countries?(country_slug)
      SS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES.include?(country_slug)
    end
      montenegro
      russia
      san-marino
      serbia
    ].freeze

    SS_MARRIAGE_COUNTRIES_WHEN_COUPLE_BRITISH = %w[lithuania].freeze

    SS_MARRIAGE_AND_PARTNERSHIP_COUNTRIES = %w[
      albania
      peru
      vietnam
    ].freeze

    CONSULAR_OPPOSITE_SEX_CIVIL_PARTNERSHIP = %w[
      bolivia
      japan
      panama
      vietnam
    ].freeze

    def offers_consular_opposite_sex_civil_partnership?(country_slug)
      CONSULAR_OPPOSITE_SEX_CIVIL_PARTNERSHIP.include?(country_slug)
    end

    def ss_marriage_countries?(country_slug)
      SS_MARRIAGE_COUNTRIES.include?(country_slug)
    end

    def ss_marriage_countries_when_couple_british?(country_slug)
      SS_MARRIAGE_COUNTRIES_WHEN_COUPLE_BRITISH.include?(country_slug)
    end

    def ss_marriage_and_partnership?(country_slug)
      SS_MARRIAGE_AND_PARTNERSHIP_COUNTRIES.include?(country_slug)
    end

    def commonwealth_country?(country_slug)
      MARRIAGE_ABROAD_COMMONWEALTH_COUNTRIES.include?(country_slug)
    end

    def british_overseas_territories?(country_slug)
      BRITISH_OVERSEAS_TERRITORIES.include?(country_slug)
    end

    def french_overseas_territories?(country_slug)
      FRENCH_OVERSEAS_TERRITORIES.include?(country_slug)
    end

    def dutch_caribbean_islands?(country_slug)
      DUTCH_CARIBBEAN_ISLANDS.include?(country_slug)
    end

    def countries_without_consular_facilities?(country_slug)
      COUNTRIES_WITHOUT_CONSULAR_FACILITIES.include?(country_slug)
    end

    def outcome_per_path_countries
      (countries_with_18_outcomes +
      countries_with_19_outcomes +
      countries_with_6_outcomes +
      countries_with_2_outcomes +
      countries_with_3_outcomes +
      countries_with_2_outcomes_marriage_or_pacs +
      countries_with_ceremony_location_outcomes +
      countries_with_1_outcome).sort
    end

    def countries_with_1_outcome
      country_outcomes(:countries_with_1_outcome)
    end

    def countries_with_2_outcomes
      country_outcomes(:countries_with_2_outcomes)
    end

    def countries_with_3_outcomes
      country_outcomes(:countries_with_3_outcomes)
    end

    def countries_with_2_outcomes_marriage_or_pacs
      country_outcomes(:countries_with_2_outcomes_marriage_or_pacs)
    end

    def countries_with_6_outcomes
      country_outcomes(:countries_with_6_outcomes)
    end

    def countries_with_18_outcomes
      country_outcomes(:countries_with_18_outcomes)
    end

    def countries_with_19_outcomes
      country_outcomes(:countries_with_19_outcomes)
    end
      REQUIRES_7_DAY_NOTICE_CEREMONY_COUNTRIES.include?(ceremony_country_slug) &&
        REQUIRED_7_DAY_NOTICE_RESIDENCY_COUNTRIES.include?(residency_country_slug)
    end
  end
end
  private

    def valid_outcomes_country_data_structure?(countries)
      countries.nil? || (countries.is_a?(Array) && countries.all? { |country| country.is_a?(String) })
    end

    def country_outcomes(key)
      countries = marriage_data.fetch(key)
      if valid_outcomes_country_data_structure?(countries)
        countries || []
      else
        raise "Country list must be an array of strings"
      end
    end

    def path_to_data_file
      Rails.root.join("config/smart_answers/marriage_abroad_data.yml")
    end
  end
end

<MSG> Add St Martin and Saint-Barthélemy to marriage abroad logic

Those two countries were recently added to the worldwide API
but had no corresponding logic to handle them. This change leads
to "no British consular facilities" outcome for both countries,
for both same and opposite sex marriages, as advised by FCO.

Those two countries also don't have many embassies, if any,
so we're always advising users to contact LOCAL relevant authorities
instead of embassies.

Note that currently the outcome has an 'os' (opposite sex) reference
in it and all the phrase keys. This is incorrect as of this commit,
but I have not renamed it here to avoid merge conflicts, as there are
changes in another branch that already started renaming those keys.

<DFF> @@ -13,11 +13,11 @@ module SmartAnswer::Calculators
 
     DUTCH_CARIBBEAN_ISLANDS = %w(aruba bonaire-st-eustatius-saba curacao st-maarten)
 
-    NON_COMMONWEALTH_COUNTRIES = %w(afghanistan albania algeria american-samoa andorra angola anguilla argentina armenia aruba austria azerbaijan bahrain belarus belgium benin bermuda bhutan bolivia bonaire-st-eustatius-saba bosnia-and-herzegovina brazil british-indian-ocean-territory british-virgin-islands bulgaria burkina-faso burma burundi cambodia cape-verde cayman-islands central-african-republic chad chile china colombia comoros congo democratic-republic-of-congo costa-rica cote-d-ivoire croatia cuba curacao czech-republic denmark djibouti dominican-republic ecuador egypt el-salvador equatorial-guinea eritrea estonia ethiopia falkland-islands fiji finland france french-guiana french-polynesia gabon georgia germany gibraltar greece guadeloupe guatemala guinea guinea-bissau haiti honduras hong-kong hungary iceland indonesia iran iraq ireland israel italy japan jordan kazakhstan south-korea kosovo kuwait kyrgyzstan laos latvia lebanon liberia libya liechtenstein lithuania luxembourg macao macedonia madagascar mali marshall-islands martinique mauritania mayotte mexico micronesia moldova monaco mongolia montenegro montserrat morocco nepal netherlands new-caledonia nicaragua niger north-korea norway oman palau panama paraguay peru philippines pitcairn-island poland portugal qatar reunion romania russia rwanda san-marino sao-tome-and-principe saudi-arabia senegal serbia slovakia slovenia somalia south-georgia-and-south-sandwich-islands south-sudan spain st-helena-ascension-and-tristan-da-cunha st-maarten st-pierre-and-miquelon sudan suriname sweden switzerland syria taiwan tajikistan thailand timor-leste togo tunisia turkmenistan turks-and-caicos-islands ukraine united-arab-emirates usa uruguay uzbekistan venezuela wallis-and-futuna western-sahara vietnam yemen zimbabwe)
+    NON_COMMONWEALTH_COUNTRIES = %w(afghanistan albania algeria american-samoa andorra angola anguilla argentina armenia aruba austria azerbaijan bahrain belarus belgium benin bermuda bhutan bolivia bonaire-st-eustatius-saba bosnia-and-herzegovina brazil british-indian-ocean-territory british-virgin-islands bulgaria burkina-faso burma burundi cambodia cape-verde cayman-islands central-african-republic chad chile china colombia comoros congo democratic-republic-of-congo costa-rica cote-d-ivoire croatia cuba curacao czech-republic denmark djibouti dominican-republic ecuador egypt el-salvador equatorial-guinea eritrea estonia ethiopia falkland-islands fiji finland france french-guiana french-polynesia gabon georgia germany gibraltar greece guadeloupe guatemala guinea guinea-bissau haiti honduras hong-kong hungary iceland indonesia iran iraq ireland israel italy japan jordan kazakhstan south-korea kosovo kuwait kyrgyzstan laos latvia lebanon liberia libya liechtenstein lithuania luxembourg macao macedonia madagascar mali marshall-islands martinique mauritania mayotte mexico micronesia moldova monaco mongolia montenegro montserrat morocco nepal netherlands new-caledonia nicaragua niger north-korea norway oman palau panama paraguay peru philippines pitcairn-island poland portugal qatar reunion romania russia rwanda saint-barthelemy san-marino sao-tome-and-principe saudi-arabia senegal serbia slovakia slovenia somalia south-georgia-and-south-sandwich-islands south-sudan spain st-helena-ascension-and-tristan-da-cunha st-maarten st-martin st-pierre-and-miquelon sudan suriname sweden switzerland syria taiwan tajikistan thailand timor-leste togo tunisia turkmenistan turks-and-caicos-islands ukraine united-arab-emirates usa uruguay uzbekistan venezuela wallis-and-futuna western-sahara vietnam yemen zimbabwe)
 
     OS_CONSULAR_CNI_COUNTRIES = %w(albania algeria angola armenia austria azerbaijan bahrain belarus belgium bolivia bosnia-and-herzegovina brazil bulgaria chile croatia cuba denmark dominican-republic el-salvador estonia ethiopia georgia germany greece guatemala honduras hungary iceland indonesia italy japan jordan kazakhstan kuwait kyrgyzstan latvia libya lithuania luxembourg macedonia moldova montenegro netherlands nepal norway oman panama poland romania russia serbia slovenia spain sudan sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
 
-    OS_NO_CONSULAR_CNI_COUNTRIES = %w(argentina burundi czech-republic democratic-republic-of-congo mexico senegal slovakia taiwan usa uruguay)
+    OS_NO_CONSULAR_CNI_COUNTRIES = %w(argentina burundi czech-republic democratic-republic-of-congo mexico saint-barthelemy senegal st-martin slovakia taiwan usa uruguay)
 
     OS_NO_MARRIAGE_CONSULAR_SERVICES = %w(afghanistan american-samoa andorra aruba benin bhutan bonaire-st-eustatius-saba burkina-faso burundi cape-verde central-african-republic chad comoros congo costa-rica cote-d-ivoire curacao djibouti equatorial-guinea eritrea gabon guinea guinea-bissau haiti hong-kong iraq israel kosovo laos liberia liechtenstein macao madagascar mali marshall-islands mauritania micronesia monaco nicaragua niger palau paraguay rwanda san-marino sao-tome-and-principe south-sudan st-maarten suriname timor-leste togo western-sahara)
 
@@ -33,7 +33,7 @@ module SmartAnswer::Calculators
 
     CP_CONSULAR_COUNTRIES = %w(bulgaria cambodia croatia cyprus guatemala japan latvia moldova panama peru philippines venezuela vietnam)
 
-    COUNTRIES_WITHOUT_CONSULAR_FACILITIES = %w(aruba slovakia curacao bonaire-st-eustatius-saba st-maarten taiwan czech-republic argentina cote-d-ivoire burundi)
+    COUNTRIES_WITHOUT_CONSULAR_FACILITIES = %w(aruba slovakia curacao bonaire-st-eustatius-saba saint-barthelemy st-maarten st-martin taiwan czech-republic argentina cote-d-ivoire burundi)
 
     SS_MARRIAGE_COUNTRIES = %w(australia azerbaijan bolivia chile china colombia dominican-republic estonia germany kosovo latvia mongolia montenegro nicaragua russia san-marino hungary serbia)
 
@@ -55,6 +55,8 @@ module SmartAnswer::Calculators
 
     OS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES = %(jordan oman qatar united-arab-emirates yemen)
 
+    SS_UNKNOWN_NO_EMBASSIES = %w(st-martin saint-barthelemy)
+
     def ss_21_days_residency_required_countries?(country_slug)
       SS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES.include?(country_slug)
     end
@@ -156,5 +158,9 @@ module SmartAnswer::Calculators
       REQUIRES_7_DAY_NOTICE_CEREMONY_COUNTRIES.include?(ceremony_country_slug) &&
         REQUIRED_7_DAY_NOTICE_RESIDENCY_COUNTRIES.include?(residency_country_slug)
     end
+
+    def ss_unknown_no_embassies?(country_slug)
+      SS_UNKNOWN_NO_EMBASSIES.include?(country_slug)
+    end
   end
 end

{'addition_count': 9, 'commit_subject': 'Add St Martin and Saint-Barthélemy to marriage abroad logic', 'deletion_count': 3, 'file_extension': '.rb', 'lang': 'rb', 'license': 'mit', 'repo_name': 'alphagov/smart-answers'}