Skip to content

Commit 6fb76e9

Browse files
committed
Merge pull request #2394 from alphagov/remove-marriage-abroad-outcome-os-consular-cni-precalculate-blocks
Remove marriage-abroad outcome_os_consular_cni precalculate blocks
2 parents 08ff605 + 8324776 commit 6fb76e9

File tree

6 files changed

+129
-46
lines changed

6 files changed

+129
-46
lines changed

lib/smart_answer/calculators/marriage_abroad_calculator.rb

+20
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,26 @@ def outcome_path_when_resident_in_ceremony_country
240240
outcome_path_when_resident_in('ceremony_country')
241241
end
242242

243+
def three_day_residency_requirement_applies?
244+
MarriageAbroadDataQuery::THREE_DAY_RESIDENCY_REQUIREMENT_COUNTRIES.include?(ceremony_country)
245+
end
246+
247+
def cni_posted_after_14_days?
248+
MarriageAbroadDataQuery::CNI_POSTED_AFTER_14_DAYS_COUNTRIES.include?(ceremony_country)
249+
end
250+
251+
def birth_certificate_required_as_supporting_document?
252+
MarriageAbroadDataQuery::NO_BIRTH_CERT_REQUIREMENT.exclude?(ceremony_country)
253+
end
254+
255+
def notary_public_ceremony_country?
256+
MarriageAbroadDataQuery::CNI_NOTARY_PUBLIC_COUNTRIES.include?(ceremony_country)
257+
end
258+
259+
def document_download_link_if_opposite_sex_resident_of_uk_countries?
260+
MarriageAbroadDataQuery::NO_DOCUMENT_DOWNLOAD_LINK_IF_OS_RESIDENT_OF_UK_COUNTRIES.exclude?(ceremony_country)
261+
end
262+
243263
private
244264

245265
def outcome_path_when_resident_in(uk_or_ceremony_country)

lib/smart_answer/calculators/marriage_abroad_data_query.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,20 @@ class MarriageAbroadDataQuery
4848

4949
SS_ALT_FEES_TABLE_OR_OUTCOME_GROUP_B = %w(azerbaijan chile dominican-republic kosovo latvia)
5050

51-
OS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES = %(jordan oman qatar yemen)
51+
OS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES = %w(jordan oman qatar yemen)
5252

5353
SS_UNKNOWN_NO_EMBASSIES = %w(st-martin saint-barthelemy)
5454

55+
THREE_DAY_RESIDENCY_REQUIREMENT_COUNTRIES = %w(albania algeria angola armenia austria azerbaijan bahrain bolivia bosnia-and-herzegovina bulgaria chile croatia cuba democratic-republic-of-congo denmark dominican-republic el-salvador estonia ethiopia georgia greece guatemala honduras hungary iceland italy kazakhstan kosovo kuwait kyrgyzstan latvia lithuania luxembourg macedonia mexico moldova montenegro nepal panama romania russia serbia slovenia sudan sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
56+
57+
NO_BIRTH_CERT_REQUIREMENT = THREE_DAY_RESIDENCY_REQUIREMENT_COUNTRIES - ['italy']
58+
59+
CNI_NOTARY_PUBLIC_COUNTRIES = %w(albania algeria angola armenia austria azerbaijan bahrain bolivia bosnia-and-herzegovina bulgaria croatia cuba estonia georgia greece iceland kazakhstan kuwait kyrgyzstan libya lithuania luxembourg mexico moldova montenegro russia serbia sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
60+
61+
NO_DOCUMENT_DOWNLOAD_LINK_IF_OS_RESIDENT_OF_UK_COUNTRIES = %w(albania algeria angola armenia austria azerbaijan bahrain bolivia bosnia-and-herzegovina bulgaria croatia cuba estonia georgia greece iceland italy japan kazakhstan kuwait kyrgyzstan libya lithuania luxembourg macedonia mexico moldova montenegro nicaragua russia serbia sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
62+
63+
CNI_POSTED_AFTER_14_DAYS_COUNTRIES = %w(jordan qatar saudi-arabia united-arab-emirates yemen)
64+
5565
def os_21_days_residency_required_countries?(country_slug)
5666
OS_21_DAYS_RESIDENCY_REQUIRED_COUNTRIES.include?(country_slug)
5767
end

lib/smart_answer_flows/marriage-abroad.rb

+1-33
Original file line numberDiff line numberDiff line change
@@ -253,39 +253,7 @@ def define
253253

254254
outcome :outcome_consular_cni_os_residing_in_third_country
255255

256-
outcome :outcome_os_consular_cni do
257-
precalculate :three_day_residency_requirement_applies do
258-
%w(albania algeria angola armenia austria azerbaijan bahrain bolivia bosnia-and-herzegovina bulgaria chile croatia cuba democratic-republic-of-congo denmark dominican-republic el-salvador estonia ethiopia georgia greece guatemala honduras hungary iceland italy kazakhstan kosovo kuwait kyrgyzstan latvia lithuania luxembourg macedonia mexico moldova montenegro nepal panama romania russia serbia slovenia sudan sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
259-
end
260-
precalculate :three_day_residency_handled_by_exception do
261-
%w(croatia italy russia)
262-
end
263-
precalculate :no_birth_cert_requirement do
264-
three_day_residency_requirement_applies - ['italy']
265-
end
266-
precalculate :cni_notary_public_countries do
267-
%w(albania algeria angola armenia austria azerbaijan bahrain bolivia bosnia-and-herzegovina bulgaria croatia cuba estonia georgia greece iceland kazakhstan kuwait kyrgyzstan libya lithuania luxembourg mexico moldova montenegro russia serbia sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
268-
end
269-
precalculate :no_document_download_link_if_os_resident_of_uk_countries do
270-
%w(albania algeria angola armenia austria azerbaijan bahrain bolivia bosnia-and-herzegovina bulgaria croatia cuba estonia georgia greece iceland italy japan kazakhstan kuwait kyrgyzstan libya lithuania luxembourg macedonia mexico moldova montenegro nicaragua russia serbia sweden tajikistan tunisia turkmenistan ukraine uzbekistan venezuela)
271-
end
272-
precalculate :cni_posted_after_14_days_countries do
273-
%w(jordan qatar saudi-arabia united-arab-emirates yemen)
274-
end
275-
precalculate :ceremony_and_residency_in_croatia do
276-
(calculator.ceremony_country == 'croatia' && calculator.resident_of_ceremony_country?)
277-
end
278-
precalculate :birth_cert_inclusion do
279-
if no_birth_cert_requirement.exclude?(calculator.ceremony_country)
280-
'_incl_birth_cert'
281-
end
282-
end
283-
precalculate :notary_public_inclusion do
284-
if cni_notary_public_countries.include?(calculator.ceremony_country) || %w(japan macedonia).include?(calculator.ceremony_country)
285-
'_notary_public'
286-
end
287-
end
288-
end
256+
outcome :outcome_os_consular_cni
289257

290258
outcome :outcome_os_france_or_fot
291259

lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb

+13-8
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<%= render partial: 'what_you_need_to_do.govspeak.erb',
3939
locals: { calculator: calculator } %>
4040

41-
<% if ceremony_and_residency_in_croatia %>
41+
<% if calculator.ceremony_country == 'croatia' && calculator.resident_of_ceremony_country? %>
4242
You'll be asked to provide a certificate of no impediment (CNI) to prove you’re allowed to marry.
4343

4444
The local registrar may also need a certificate of custom and law, which confirms the marriage is valid - the Embassy in Zagreb can provide this.
@@ -75,7 +75,7 @@
7575
<%= render partial: 'cni_at_local_register_office.govspeak.erb' %>
7676
<%= render partial: 'cni_issued_locally_validity.govspeak.erb',
7777
locals: { calculator: calculator } %>
78-
<% if cni_posted_after_14_days_countries.include?(calculator.ceremony_country) %>
78+
<% if calculator.cni_posted_after_14_days? %>
7979
They’ll post your notice, and as long as nobody has registered an objection after 14 days, they’ll issue your CNI.
8080

8181
<% end -%>
@@ -136,7 +136,7 @@
136136

137137
<% end %>
138138

139-
<% if three_day_residency_handled_by_exception.exclude?(calculator.ceremony_country) && three_day_residency_requirement_applies.include?(calculator.ceremony_country) %>
139+
<% if %w(croatia italy russia).exclude?(calculator.ceremony_country) && calculator.three_day_residency_requirement_applies? %>
140140
<%= render partial: "three_day_residency_requirement.govspeak.erb",
141141
locals: {
142142
country_name_lowercase_prefix: calculator.country_name_lowercase_prefix
@@ -247,7 +247,7 @@
247247
<% elsif calculator.resident_outside_of_uk? && calculator.ceremony_country == 'macao' %>
248248
<%= render partial: 'required_supporting_documents_macao.govspeak.erb' %>
249249
<% elsif calculator.resident_of_ceremony_country? %>
250-
<% if birth_cert_inclusion && notary_public_inclusion %>
250+
<% if calculator.birth_certificate_required_as_supporting_document? && (calculator.notary_public_ceremony_country? || %w(japan macedonia).include?(calculator.ceremony_country)) %>
251251
You’ll need to provide supporting documents, including:
252252

253253
- your passport
@@ -256,7 +256,7 @@
256256
- equivalent documents for your partner
257257

258258

259-
<% elsif birth_cert_inclusion %>
259+
<% elsif calculator.birth_certificate_required_as_supporting_document? %>
260260
You’ll need to provide supporting documents, including:
261261

262262
- your passport
@@ -265,7 +265,7 @@
265265
- equivalent documents for your partner
266266

267267

268-
<% elsif notary_public_inclusion %>
268+
<% elsif (calculator.notary_public_ceremony_country? || %w(japan macedonia).include?(calculator.ceremony_country)) %>
269269
You’ll need to provide supporting documents, including:
270270

271271
- your passport
@@ -303,7 +303,12 @@
303303

304304
<% end %>
305305
<% else %>
306-
<% if calculator.partner_is_same_sex? || no_document_download_link_if_os_resident_of_uk_countries.exclude?(calculator.ceremony_country) && (cni_notary_public_countries + %w(macedonia) - %w(greece tunisia)).include?(calculator.ceremony_country) %>
306+
<% if calculator.partner_is_same_sex? ||
307+
(
308+
calculator.document_download_link_if_opposite_sex_resident_of_uk_countries? &&
309+
(calculator.notary_public_ceremony_country? || %w(macedonia).include?(calculator.ceremony_country)) &&
310+
%w(greece tunisia).exclude?(calculator.ceremony_country)
311+
) %>
307312
<%= render partial: 'download_and_fill_notice_and_affidavit_but_not_sign.govspeak.erb' %>
308313

309314
<% end %>
@@ -357,7 +362,7 @@
357362

358363
[Make an appointment to collect your CNI at the embassy in Athens](https://www.consular-appointments.service.gov.uk/fco/#!/british-embassy-athens/certificate-of-no-impediment/slot_picker).
359364

360-
<% elsif cni_notary_public_countries.include?(calculator.ceremony_country) %>
365+
<% elsif calculator.notary_public_ceremony_country? %>
361366
###What happens next
362367

363368
The embassy or notary public will charge a fee for taking the oath.

test/data/marriage-abroad-files.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
lib/smart_answer_flows/marriage-abroad.rb: 53f3fd0c409d6d5cb3980fbc7ecc3b1f
2+
lib/smart_answer_flows/marriage-abroad.rb: 533e06d2ce695e887bd2f780805c460b
33
test/data/marriage-abroad-questions-and-responses.yml: 87f39a00d77fe0566a79e5cddbca765e
44
test/data/marriage-abroad-responses-and-expected-results.yml: c388fc820b41309bb7594e9ef908a70e
55
lib/smart_answer_flows/marriage-abroad/marriage_abroad.govspeak.erb: b4d0cfc1c7c4776d968c9b5b6df85027
@@ -105,7 +105,7 @@ lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_bot.govspeak.erb: f9c
105105
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_cambodia.govspeak.erb: b693e25f4030a1d19c6acd7cf1b3debe
106106
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_colombia.govspeak.erb: a0860f0581acfa1e5533f3114569301c
107107
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_commonwealth.govspeak.erb: 8709a00e420b96ca7378b89053e638f1
108-
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb: 8d8a0e2cff275e3b6e14fe4b79d153a1
108+
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb: ec05977ac98e4d4fe0110b4a18bbaa41
109109
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb: 71d74db77499d680423d7586ba9e0e61
110110
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_germany.govspeak.erb: e5e8a3e5209c68f513e9dbe145a5b671
111111
lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_hong_kong.govspeak.erb: 9c1686c0a3ba24dff0297e4e04f2fae6
@@ -133,8 +133,8 @@ lib/smart_answer_flows/marriage-abroad/questions/legal_residency.govspeak.erb: 7
133133
lib/smart_answer_flows/marriage-abroad/questions/marriage_or_pacs.govspeak.erb: a51aecfac697188f90ca9efefcb2e0ea
134134
lib/smart_answer_flows/marriage-abroad/questions/partner_opposite_or_same_sex.govspeak.erb: 40d0c99a5be50f0625c6562f06fe4afd
135135
lib/smart_answer_flows/marriage-abroad/questions/what_is_your_partners_nationality.govspeak.erb: 80e04f36c75c232bede1a244d621471e
136-
lib/smart_answer/calculators/marriage_abroad_calculator.rb: 96c48c4f5edd8bec13854adf2fdcd974
136+
lib/smart_answer/calculators/marriage_abroad_calculator.rb: 6329b517874ecf732cf3b48e0ce8601f
137137
lib/smart_answer_flows/shared/_overseas_passports_embassies.govspeak.erb: 2f521bae99c2f48b49d07bcb283a8063
138-
lib/smart_answer/calculators/marriage_abroad_data_query.rb: 80043ce123ab86befc4def86361abb81
138+
lib/smart_answer/calculators/marriage_abroad_data_query.rb: 1d222b16a790bcf3f7b02c97b0e0b5b0
139139
lib/smart_answer/calculators/country_name_formatter.rb: 69a0726640385f42de50b80fdb144ff8
140140
lib/smart_answer/calculators/registrations_data_query.rb: 563c5db7d7272bc07bd636a92b40f3ce

test/unit/calculators/marriage_abroad_calculator_test.rb

+80
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,86 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase
760760
assert_equal expected_path, calculator.outcome_path_when_resident_in_ceremony_country
761761
end
762762
end
763+
764+
context '#three_day_residency_requirement_applies?' do
765+
should 'return true if ceremony country requires 3 day residency' do
766+
calculator = MarriageAbroadCalculator.new
767+
calculator.ceremony_country = 'albania'
768+
769+
assert calculator.three_day_residency_requirement_applies?
770+
end
771+
772+
should 'return false if ceremony country does not require 3 days residency' do
773+
calculator = MarriageAbroadCalculator.new
774+
calculator.ceremony_country = 'country-not-requiring-three-day-residency'
775+
776+
refute calculator.three_day_residency_requirement_applies?
777+
end
778+
end
779+
780+
context '#cni_posted_after_14_days?' do
781+
should 'return true if ceremony country will post notice after 14 days' do
782+
calculator = MarriageAbroadCalculator.new
783+
calculator.ceremony_country = 'jordan'
784+
785+
assert calculator.cni_posted_after_14_days?
786+
end
787+
788+
should 'return false if ceremony country will not post notice after 14 days' do
789+
calculator = MarriageAbroadCalculator.new
790+
calculator.ceremony_country = 'ceremony-country-not-posting-notice-after-14-days'
791+
792+
refute calculator.cni_posted_after_14_days?
793+
end
794+
end
795+
796+
context '#birth_certificate_required_as_supporting_document?' do
797+
should 'return true when a birth certificate is required' do
798+
calculator = MarriageAbroadCalculator.new
799+
calculator.ceremony_country = 'ceremony-country-requiring-birth-certificate'
800+
801+
assert calculator.birth_certificate_required_as_supporting_document?
802+
end
803+
804+
should 'return false when no birth certificate is required' do
805+
calculator = MarriageAbroadCalculator.new
806+
calculator.ceremony_country = 'albania'
807+
808+
refute calculator.birth_certificate_required_as_supporting_document?
809+
end
810+
end
811+
812+
context '#notary_public_ceremony_country?' do
813+
should 'return true if country has a notary public' do
814+
calculator = MarriageAbroadCalculator.new
815+
calculator.ceremony_country = 'albania'
816+
817+
assert calculator.notary_public_ceremony_country?
818+
end
819+
820+
should 'return false if country has no notary public' do
821+
calculator = MarriageAbroadCalculator.new
822+
calculator.ceremony_country = 'country-without-notary-public'
823+
824+
refute calculator.notary_public_ceremony_country?
825+
end
826+
end
827+
828+
context '#document_download_link_if_opposite_sex_resident_of_uk_countries?' do
829+
should 'return true if you can download forms' do
830+
calculator = MarriageAbroadCalculator.new
831+
calculator.ceremony_country = 'country-allowing-you-to-download-forms'
832+
833+
assert calculator.document_download_link_if_opposite_sex_resident_of_uk_countries?
834+
end
835+
836+
should "return false if you can't download forms" do
837+
calculator = MarriageAbroadCalculator.new
838+
calculator.ceremony_country = 'albania'
839+
840+
refute calculator.document_download_link_if_opposite_sex_resident_of_uk_countries?
841+
end
842+
end
763843
end
764844
end
765845
end

0 commit comments

Comments
 (0)