From eb26cbf1cfac4d2e7731120eace4dfde201a2a82 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Thu, 25 Feb 2016 17:07:55 +1300 Subject: [PATCH 01/28] Use multiple lines for long conditionals in marriage-abroad I think this is going to make it easier to make changes as I move methods move from the `MarriageAbroadDataQuery` to the `MarriageAbroadCalculator`. --- lib/smart_answer_flows/marriage-abroad.rb | 28 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 3b23ba03c54..f5a203236ff 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -169,7 +169,12 @@ def define :outcome_os_kuwait elsif calculator.ceremony_country == 'japan' :outcome_os_japan - elsif calculator.resident_of_third_country? && (data_query.os_consular_cni_countries?(calculator.ceremony_country) || %w(kosovo).include?(calculator.ceremony_country) || data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country)) + elsif calculator.resident_of_third_country? && + ( + data_query.os_consular_cni_countries?(calculator.ceremony_country) || + %w(kosovo).include?(calculator.ceremony_country) || + data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country) + ) :outcome_consular_cni_os_residing_in_third_country elsif calculator.ceremony_country == 'norway' && calculator.resident_of_third_country? :outcome_consular_cni_os_residing_in_third_country @@ -193,7 +198,12 @@ def define :outcome_os_poland elsif calculator.ceremony_country == 'slovenia' :outcome_os_slovenia - elsif data_query.os_consular_cni_countries?(calculator.ceremony_country) || (calculator.resident_of_uk? && data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country)) || data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country) + elsif data_query.os_consular_cni_countries?(calculator.ceremony_country) || + ( + calculator.resident_of_uk? && + data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) + ) || + data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country) :outcome_os_consular_cni elsif calculator.ceremony_country == "finland" && calculator.resident_of_uk? :outcome_os_consular_cni @@ -201,11 +211,16 @@ def define :outcome_os_consular_cni elsif data_query.os_affirmation_countries?(calculator.ceremony_country) :outcome_os_affirmation - elsif data_query.commonwealth_country?(calculator.ceremony_country) || calculator.ceremony_country == 'zimbabwe' + elsif data_query.commonwealth_country?(calculator.ceremony_country) || + calculator.ceremony_country == 'zimbabwe' :outcome_os_commonwealth elsif data_query.british_overseas_territories?(calculator.ceremony_country) :outcome_os_bot - elsif data_query.os_no_consular_cni_countries?(calculator.ceremony_country) || (calculator.resident_outside_of_uk? && data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country)) + elsif data_query.os_no_consular_cni_countries?(calculator.ceremony_country) || + ( + calculator.resident_outside_of_uk? && + data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) + ) :outcome_os_no_cni elsif data_query.os_marriage_via_local_authorities?(calculator.ceremony_country) :outcome_marriage_via_local_authorities @@ -224,7 +239,10 @@ def define elsif calculator.ceremony_country == "germany" && calculator.partner_is_national_of_ceremony_country? :outcome_cp_or_equivalent elsif (data_query.ss_marriage_countries?(calculator.ceremony_country)) || - (data_query.ss_marriage_countries_when_couple_british?(calculator.ceremony_country) && calculator.partner_british?) || + ( + data_query.ss_marriage_countries_when_couple_british?(calculator.ceremony_country) && + calculator.partner_british? + ) || (data_query.ss_marriage_and_partnership?(calculator.ceremony_country)) :outcome_ss_marriage elsif data_query.cp_equivalent_countries?(calculator.ceremony_country) From 5b316c5c74b734621799404ef6f0f8c1618a83a2 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Thu, 25 Feb 2016 17:25:17 +1300 Subject: [PATCH 02/28] Remove unnecessary parenthesis --- lib/smart_answer_flows/marriage-abroad.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index f5a203236ff..d0d0e6d3b88 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -238,12 +238,12 @@ def define :outcome_ss_marriage_not_possible elsif calculator.ceremony_country == "germany" && calculator.partner_is_national_of_ceremony_country? :outcome_cp_or_equivalent - elsif (data_query.ss_marriage_countries?(calculator.ceremony_country)) || + elsif data_query.ss_marriage_countries?(calculator.ceremony_country) || ( data_query.ss_marriage_countries_when_couple_british?(calculator.ceremony_country) && calculator.partner_british? ) || - (data_query.ss_marriage_and_partnership?(calculator.ceremony_country)) + data_query.ss_marriage_and_partnership?(calculator.ceremony_country) :outcome_ss_marriage elsif data_query.cp_equivalent_countries?(calculator.ceremony_country) :outcome_cp_or_equivalent From 5fc23352d88e3a0b66d67269c402c91d8030727c Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 16:45:47 +1300 Subject: [PATCH 03/28] Add #ceremony_country_is_french_overseas_territory? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. --- .../calculators/marriage_abroad_calculator.rb | 6 +++++- lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../outcomes/outcome_os_france_or_fot.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 02fb32a480b..2361bbf4c67 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -113,7 +113,7 @@ def country_name_uppercase_prefix def country_name_partner_residence if @data_query.british_overseas_territories?(ceremony_country) 'British (overseas territories citizen)' - elsif @data_query.french_overseas_territories?(ceremony_country) + elsif ceremony_country_is_french_overseas_territory? 'French' elsif @data_query.dutch_caribbean_islands?(ceremony_country) 'Dutch' @@ -131,5 +131,9 @@ def embassy_or_consulate_ceremony_country 'embassy' end end + + def ceremony_country_is_french_overseas_territory? + @data_query.french_overseas_territories?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index d0d0e6d3b88..662a1221757 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -36,7 +36,7 @@ def define :partner_opposite_or_same_sex? elsif %w(france monaco new-caledonia wallis-and-futuna).include?(calculator.ceremony_country) :marriage_or_pacs? - elsif data_query.french_overseas_territories?(calculator.ceremony_country) + elsif calculator.ceremony_country_is_french_overseas_territory? :outcome_os_france_or_fot else :legal_residency? diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb index ad10c5d0570..08f895e50a7 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb @@ -3,7 +3,7 @@ <% end %> <% content_for :body do %> - <% if data_query.french_overseas_territories?(calculator.ceremony_country) %> + <% if calculator.ceremony_country_is_french_overseas_territory? %> <%= calculator.country_name_uppercase_prefix %> is an overseas department or territory of France. The rules and requirements for getting married there are similar to France. <% end %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index bf083d809ca..f787a2826a9 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -469,6 +469,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'embassy', @calculator.embassy_or_consulate_ceremony_country end end + + context '#ceremony_country_is_french_overseas_territory?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:french_overseas_territories?).with('ceremony-country').returns('french-overseas-territory') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'french-overseas-territory', calculator.ceremony_country_is_french_overseas_territory? + end + end end end end From 10e53fb9f05d4d9ec628e9bcfcb53aab644d5b62 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 16:55:43 +1300 Subject: [PATCH 04/28] Add #opposite_sex_consular_cni_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 4 ++-- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 2361bbf4c67..51504743ad1 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -135,5 +135,9 @@ def embassy_or_consulate_ceremony_country def ceremony_country_is_french_overseas_territory? @data_query.french_overseas_territories?(ceremony_country) end + + def opposite_sex_consular_cni_country? + @data_query.os_consular_cni_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 662a1221757..e9a0a7c034e 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -171,7 +171,7 @@ def define :outcome_os_japan elsif calculator.resident_of_third_country? && ( - data_query.os_consular_cni_countries?(calculator.ceremony_country) || + calculator.opposite_sex_consular_cni_country? || %w(kosovo).include?(calculator.ceremony_country) || data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country) ) @@ -198,7 +198,7 @@ def define :outcome_os_poland elsif calculator.ceremony_country == 'slovenia' :outcome_os_slovenia - elsif data_query.os_consular_cni_countries?(calculator.ceremony_country) || + elsif calculator.opposite_sex_consular_cni_country? || ( calculator.resident_of_uk? && data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index f787a2826a9..86d1d515594 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -480,6 +480,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'french-overseas-territory', calculator.ceremony_country_is_french_overseas_territory? end end + + context '#opposite_sex_consular_cni_country' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_consular_cni_countries?).with('ceremony-country').returns('opposite-sex-consular-cni-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-consular-cni-country', calculator.opposite_sex_consular_cni_country? + end + end end end end From ec6de12a36790c73fd02a3ff91dd640aef992fe2 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:01:08 +1300 Subject: [PATCH 05/28] Add #opposite_sex_consular_cni_in_nearby_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 4 ++-- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 51504743ad1..ca1979d507a 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -139,5 +139,9 @@ def ceremony_country_is_french_overseas_territory? def opposite_sex_consular_cni_country? @data_query.os_consular_cni_countries?(ceremony_country) end + + def opposite_sex_consular_cni_in_nearby_country? + @data_query.os_consular_cni_in_nearby_country?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index e9a0a7c034e..ecbcc608f94 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -173,7 +173,7 @@ def define ( calculator.opposite_sex_consular_cni_country? || %w(kosovo).include?(calculator.ceremony_country) || - data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country) + calculator.opposite_sex_consular_cni_in_nearby_country? ) :outcome_consular_cni_os_residing_in_third_country elsif calculator.ceremony_country == 'norway' && calculator.resident_of_third_country? @@ -203,7 +203,7 @@ def define calculator.resident_of_uk? && data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) ) || - data_query.os_consular_cni_in_nearby_country?(calculator.ceremony_country) + calculator.opposite_sex_consular_cni_in_nearby_country? :outcome_os_consular_cni elsif calculator.ceremony_country == "finland" && calculator.resident_of_uk? :outcome_os_consular_cni diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 86d1d515594..f73d17fd513 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -491,6 +491,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-consular-cni-country', calculator.opposite_sex_consular_cni_country? end end + + context '#opposite_sex_consular_cni_in_nearby_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_consular_cni_in_nearby_country?).with('ceremony-country').returns('opposite-sex-consular-cni-in-nearby-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-consular-cni-in-nearby-country', calculator.opposite_sex_consular_cni_in_nearby_country? + end + end end end end From 48cbaececd32ec7b084f8945e04c3e141d139d5b Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:09:27 +1300 Subject: [PATCH 06/28] Add #opposite_sex_no_marriage_related_consular_services_in_ceremony_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 4 ++-- ...ular_cni_os_residing_in_third_country.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index ca1979d507a..e90466cf3fe 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -143,5 +143,9 @@ def opposite_sex_consular_cni_country? def opposite_sex_consular_cni_in_nearby_country? @data_query.os_consular_cni_in_nearby_country?(ceremony_country) end + + def opposite_sex_no_marriage_related_consular_services_in_ceremony_country? + @data_query.os_no_marriage_related_consular_services?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index ecbcc608f94..e354dd86132 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -201,7 +201,7 @@ def define elsif calculator.opposite_sex_consular_cni_country? || ( calculator.resident_of_uk? && - data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) + calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? ) || calculator.opposite_sex_consular_cni_in_nearby_country? :outcome_os_consular_cni @@ -219,7 +219,7 @@ def define elsif data_query.os_no_consular_cni_countries?(calculator.ceremony_country) || ( calculator.resident_outside_of_uk? && - data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) + calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? ) :outcome_os_no_cni elsif data_query.os_marriage_via_local_authorities?(calculator.ceremony_country) diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_consular_cni_os_residing_in_third_country.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_consular_cni_os_residing_in_third_country.govspeak.erb index 1e883b9276f..7e4a3ff0c8f 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_consular_cni_os_residing_in_third_country.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_consular_cni_os_residing_in_third_country.govspeak.erb @@ -9,7 +9,7 @@ <%= render partial: 'get_legal_and_travel_advice.govspeak.erb', locals: { calculator: calculator } %> - <% if data_query.os_no_marriage_related_consular_services?(calculator.ceremony_country) %> + <% if calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? %> <%= render partial: 'cni_os_consular_facilities_unavailable.govspeak.erb', locals: { calculator: calculator } %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index f73d17fd513..b9d552ac3b8 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -502,6 +502,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-consular-cni-in-nearby-country', calculator.opposite_sex_consular_cni_in_nearby_country? end end + + context '#opposite_sex_no_marriage_related_consular_services_in_ceremony_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_no_marriage_related_consular_services?).with('ceremony-country').returns('opposite-sex-no-marriage-related-consular-servies') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-no-marriage-related-consular-servies', calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? + end + end end end end From ff31e8683a88eed5edc7d111b3b3667c0fae34c0 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:25:19 +1300 Subject: [PATCH 07/28] Add #opposite_sex_affirmation_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index e90466cf3fe..147cd5db5be 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -147,5 +147,9 @@ def opposite_sex_consular_cni_in_nearby_country? def opposite_sex_no_marriage_related_consular_services_in_ceremony_country? @data_query.os_no_marriage_related_consular_services?(ceremony_country) end + + def opposite_sex_affirmation_country? + @data_query.os_affirmation_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index e354dd86132..85f3317f0db 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -209,7 +209,7 @@ def define :outcome_os_consular_cni elsif calculator.ceremony_country == "norway" && calculator.resident_of_uk? :outcome_os_consular_cni - elsif data_query.os_affirmation_countries?(calculator.ceremony_country) + elsif calculator.opposite_sex_affirmation_country? :outcome_os_affirmation elsif data_query.commonwealth_country?(calculator.ceremony_country) || calculator.ceremony_country == 'zimbabwe' diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index b9d552ac3b8..bdf6b43b594 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -513,6 +513,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-no-marriage-related-consular-servies', calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? end end + + context '#opposite_sex_affirmation_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_affirmation_countries?).with('ceremony-country').returns('opposite-sex-affirmation-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-affirmation-country', calculator.opposite_sex_affirmation_country? + end + end end end end From 5ce3c9b177e28b8ecd2bc2481500423419af380b Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:32:25 +1300 Subject: [PATCH 08/28] Add #ceremony_country_in_the_commonwealth? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. Interestingly we have another, different, concept of Commonwealth countries in `RegistrationsDataQuery`. I've made a separate note to investigate that. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 147cd5db5be..5820c731c20 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -151,5 +151,9 @@ def opposite_sex_no_marriage_related_consular_services_in_ceremony_country? def opposite_sex_affirmation_country? @data_query.os_affirmation_countries?(ceremony_country) end + + def ceremony_country_in_the_commonwealth? + @data_query.commonwealth_country?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 85f3317f0db..a19cb5bab33 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -211,7 +211,7 @@ def define :outcome_os_consular_cni elsif calculator.opposite_sex_affirmation_country? :outcome_os_affirmation - elsif data_query.commonwealth_country?(calculator.ceremony_country) || + elsif calculator.ceremony_country_in_the_commonwealth? || calculator.ceremony_country == 'zimbabwe' :outcome_os_commonwealth elsif data_query.british_overseas_territories?(calculator.ceremony_country) diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index bdf6b43b594..471e52dcb4c 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -524,6 +524,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-affirmation-country', calculator.opposite_sex_affirmation_country? end end + + context '#ceremony_country_in_the_commonwealth' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:commonwealth_country?).with('ceremony-country').returns('commonwealth-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'commonwealth-country', calculator.ceremony_country_in_the_commonwealth? + end + end end end end From 6a8ecab376435c42c1c62fe217fe35955937e5bd Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:35:09 +1300 Subject: [PATCH 09/28] Add #ceremony_country_is_british_overseas_territory? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. --- .../calculators/marriage_abroad_calculator.rb | 6 +++++- lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 5820c731c20..9a02d895864 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -111,7 +111,7 @@ def country_name_uppercase_prefix end def country_name_partner_residence - if @data_query.british_overseas_territories?(ceremony_country) + if ceremony_country_is_british_overseas_territory? 'British (overseas territories citizen)' elsif ceremony_country_is_french_overseas_territory? 'French' @@ -155,5 +155,9 @@ def opposite_sex_affirmation_country? def ceremony_country_in_the_commonwealth? @data_query.commonwealth_country?(ceremony_country) end + + def ceremony_country_is_british_overseas_territory? + @data_query.british_overseas_territories?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index a19cb5bab33..1556c9b9f93 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -214,7 +214,7 @@ def define elsif calculator.ceremony_country_in_the_commonwealth? || calculator.ceremony_country == 'zimbabwe' :outcome_os_commonwealth - elsif data_query.british_overseas_territories?(calculator.ceremony_country) + elsif calculator.ceremony_country_is_british_overseas_territory? :outcome_os_bot elsif data_query.os_no_consular_cni_countries?(calculator.ceremony_country) || ( diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 471e52dcb4c..46bc2859978 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -535,6 +535,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'commonwealth-country', calculator.ceremony_country_in_the_commonwealth? end end + + context '#ceremony_country_is_british_overseas_territory?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:british_overseas_territories?).with('ceremony-country').returns('british-overseas-territory') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'british-overseas-territory', calculator.ceremony_country_is_british_overseas_territory? + end + end end end end From fa0b2ffc56fa906acf80cd6e7f6fed2a81e1f3ba Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:47:34 +1300 Subject: [PATCH 10/28] Add #opposite_sex_no_consular_cni_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 9a02d895864..d115c350fcf 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -159,5 +159,9 @@ def ceremony_country_in_the_commonwealth? def ceremony_country_is_british_overseas_territory? @data_query.british_overseas_territories?(ceremony_country) end + + def opposite_sex_no_consular_cni_country? + @data_query.os_no_consular_cni_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 1556c9b9f93..8f0d888ccf9 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -216,7 +216,7 @@ def define :outcome_os_commonwealth elsif calculator.ceremony_country_is_british_overseas_territory? :outcome_os_bot - elsif data_query.os_no_consular_cni_countries?(calculator.ceremony_country) || + elsif calculator.opposite_sex_no_consular_cni_country? || ( calculator.resident_outside_of_uk? && calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 46bc2859978..f225098459e 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -546,6 +546,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'british-overseas-territory', calculator.ceremony_country_is_british_overseas_territory? end end + + context '#opposite_sex_no_consular_cni_country' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_no_consular_cni_countries?).with('ceremony-country').returns('opposite-sex-no-consular-cni-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-no-consular-cni-country', calculator.opposite_sex_no_consular_cni_country? + end + end end end end From 7c3c6f5e97511dbf792d1cd64d1ab1f93f16b5f9 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 17:55:17 +1300 Subject: [PATCH 11/28] Add #opposite_sex_marriage_via_local_authorities? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index d115c350fcf..a056f305171 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -163,5 +163,9 @@ def ceremony_country_is_british_overseas_territory? def opposite_sex_no_consular_cni_country? @data_query.os_no_consular_cni_countries?(ceremony_country) end + + def opposite_sex_marriage_via_local_authorities? + @data_query.os_marriage_via_local_authorities?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 8f0d888ccf9..2930d47f696 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -222,7 +222,7 @@ def define calculator.opposite_sex_no_marriage_related_consular_services_in_ceremony_country? ) :outcome_os_no_cni - elsif data_query.os_marriage_via_local_authorities?(calculator.ceremony_country) + elsif calculator.opposite_sex_marriage_via_local_authorities? :outcome_marriage_via_local_authorities elsif data_query.os_other_countries?(calculator.ceremony_country) :outcome_os_other_countries diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index f225098459e..9d0f301ec2f 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -557,6 +557,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-no-consular-cni-country', calculator.opposite_sex_no_consular_cni_country? end end + + context '#opposite_sex_marriage_via_local_authorities?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_marriage_via_local_authorities?).with('ceremony-country').returns('opposite-sex-marriage-via-local-authorities') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-marriage-via-local-authorities', calculator.opposite_sex_marriage_via_local_authorities? + end + end end end end From b2449b5504869a70d2d1b306a4abf917d5a6bf90 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:03:23 +1300 Subject: [PATCH 12/28] Add #opposite_sex_in_other_countries? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index a056f305171..c9493da8c34 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -167,5 +167,9 @@ def opposite_sex_no_consular_cni_country? def opposite_sex_marriage_via_local_authorities? @data_query.os_marriage_via_local_authorities?(ceremony_country) end + + def opposite_sex_in_other_countries? + @data_query.os_other_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 2930d47f696..e8dedf0abb1 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -224,7 +224,7 @@ def define :outcome_os_no_cni elsif calculator.opposite_sex_marriage_via_local_authorities? :outcome_marriage_via_local_authorities - elsif data_query.os_other_countries?(calculator.ceremony_country) + elsif calculator.opposite_sex_in_other_countries? :outcome_os_other_countries end elsif calculator.partner_is_same_sex? diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 9d0f301ec2f..514cdd6914a 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -568,6 +568,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-marriage-via-local-authorities', calculator.opposite_sex_marriage_via_local_authorities? end end + + context '#opposite_sex_in_other_countries?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_other_countries?).with('ceremony-country').returns('opposite-sex-in-other-countries') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'opposite-sex-in-other-countries', calculator.opposite_sex_in_other_countries? + end + end end end end From b7fca434b4b8f10fcb62764d400c2a0b5e797465 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:17:18 +1300 Subject: [PATCH 13/28] Add #same_sex_ceremony_country_unknown_or_has_no_embassies? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. For reference, the `#ss_unknown_no_embassies?` method was introduced in 6a9a7b84b1af57b9d6d263a18dc5611400daa4e4. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../outcomes/outcome_os_no_cni.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index c9493da8c34..abd0deb7fe3 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -171,5 +171,9 @@ def opposite_sex_marriage_via_local_authorities? def opposite_sex_in_other_countries? @data_query.os_other_countries?(ceremony_country) end + + def same_sex_ceremony_country_unknown_or_has_no_embassies? + @data_query.ss_unknown_no_embassies?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index e8dedf0abb1..65ddb56b605 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -230,7 +230,7 @@ def define elsif calculator.partner_is_same_sex? if %w(belgium norway).include?(calculator.ceremony_country) :outcome_ss_affirmation - elsif data_query.ss_unknown_no_embassies?(calculator.ceremony_country) + elsif calculator.same_sex_ceremony_country_unknown_or_has_no_embassies? :outcome_os_no_cni elsif calculator.ceremony_country == "malta" :outcome_ss_marriage_malta diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb index 0af520df620..6308c1d4df2 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb @@ -15,7 +15,7 @@ <% end %> <% else %> - <% if calculator.resident_outside_of_uk? || data_query.ss_unknown_no_embassies?(calculator.ceremony_country) %> + <% if calculator.resident_outside_of_uk? || calculator.same_sex_ceremony_country_unknown_or_has_no_embassies? %> <%= render partial: 'contact_local_authorities_in_country_marriage.govspeak.erb', locals: { calculator: calculator } %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 514cdd6914a..b43b24aad89 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -579,6 +579,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'opposite-sex-in-other-countries', calculator.opposite_sex_in_other_countries? end end + + context '#same_sex_ceremony_country_unknown_or_has_no_embassies?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:ss_unknown_no_embassies?).with('ceremony-country').returns('unknown-or-no-embassies') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'unknown-or-no-embassies', calculator.same_sex_ceremony_country_unknown_or_has_no_embassies? + end + end end end end From 7ffce0977a04c75fb4346bf72c4d57c4a790953c Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:33:22 +1300 Subject: [PATCH 14/28] Add #same_sex_marriage_not_possible? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index abd0deb7fe3..bb16f647fd6 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -175,5 +175,9 @@ def opposite_sex_in_other_countries? def same_sex_ceremony_country_unknown_or_has_no_embassies? @data_query.ss_unknown_no_embassies?(ceremony_country) end + + def same_sex_marriage_not_possible? + @data_query.ss_marriage_not_possible?(ceremony_country, self) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 65ddb56b605..27185786a01 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -234,7 +234,7 @@ def define :outcome_os_no_cni elsif calculator.ceremony_country == "malta" :outcome_ss_marriage_malta - elsif data_query.ss_marriage_not_possible?(calculator.ceremony_country, calculator) + elsif calculator.same_sex_marriage_not_possible? :outcome_ss_marriage_not_possible elsif calculator.ceremony_country == "germany" && calculator.partner_is_national_of_ceremony_country? :outcome_cp_or_equivalent diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index b43b24aad89..fdfb3d605c5 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -590,6 +590,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'unknown-or-no-embassies', calculator.same_sex_ceremony_country_unknown_or_has_no_embassies? end end + + context '#same_sex_marriage_not_possible?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + calculator = MarriageAbroadCalculator.new(data_query: data_query) + data_query.stubs(:ss_marriage_not_possible?).with('ceremony-country', calculator).returns('same-sex-marriage-not-possible') + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'same-sex-marriage-not-possible', calculator.same_sex_marriage_not_possible? + end + end end end end From 68cda9cec70d646b82c0ee6d866c212b0fd62920 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:38:08 +1300 Subject: [PATCH 15/28] Add #same_sex_marriage_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 6 +++++- lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index bb16f647fd6..ef392c0f7b4 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -89,7 +89,7 @@ def overseas_passports_embassies end def marriage_and_partnership_phrases - if @data_query.ss_marriage_countries?(ceremony_country) || @data_query.ss_marriage_countries_when_couple_british?(ceremony_country) + if same_sex_marriage_country? || @data_query.ss_marriage_countries_when_couple_british?(ceremony_country) 'ss_marriage' elsif @data_query.ss_marriage_and_partnership?(ceremony_country) 'ss_marriage_and_partnership' @@ -179,5 +179,9 @@ def same_sex_ceremony_country_unknown_or_has_no_embassies? def same_sex_marriage_not_possible? @data_query.ss_marriage_not_possible?(ceremony_country, self) end + + def same_sex_marriage_country? + @data_query.ss_marriage_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 27185786a01..86d34a488ad 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -238,7 +238,7 @@ def define :outcome_ss_marriage_not_possible elsif calculator.ceremony_country == "germany" && calculator.partner_is_national_of_ceremony_country? :outcome_cp_or_equivalent - elsif data_query.ss_marriage_countries?(calculator.ceremony_country) || + elsif calculator.same_sex_marriage_country? || ( data_query.ss_marriage_countries_when_couple_british?(calculator.ceremony_country) && calculator.partner_british? diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index fdfb3d605c5..62eb73a4cae 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -601,6 +601,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'same-sex-marriage-not-possible', calculator.same_sex_marriage_not_possible? end end + + context '#same_sex_marriage_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:ss_marriage_countries?).with('ceremony-country').returns('same-sex-marriage-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'same-sex-marriage-country', calculator.same_sex_marriage_country? + end + end end end end From 8d901a4d7d7aaff3e1d6f30842e946ccbc9f132d Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:41:16 +1300 Subject: [PATCH 16/28] Add #same_sex_marriage_country_when_couple_british? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 6 +++++- lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index ef392c0f7b4..5e3898d2f19 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -89,7 +89,7 @@ def overseas_passports_embassies end def marriage_and_partnership_phrases - if same_sex_marriage_country? || @data_query.ss_marriage_countries_when_couple_british?(ceremony_country) + if same_sex_marriage_country? || same_sex_marriage_country_when_couple_british? 'ss_marriage' elsif @data_query.ss_marriage_and_partnership?(ceremony_country) 'ss_marriage_and_partnership' @@ -183,5 +183,9 @@ def same_sex_marriage_not_possible? def same_sex_marriage_country? @data_query.ss_marriage_countries?(ceremony_country) end + + def same_sex_marriage_country_when_couple_british? + @data_query.ss_marriage_countries_when_couple_british?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 86d34a488ad..b7e093255ae 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -240,7 +240,7 @@ def define :outcome_cp_or_equivalent elsif calculator.same_sex_marriage_country? || ( - data_query.ss_marriage_countries_when_couple_british?(calculator.ceremony_country) && + calculator.same_sex_marriage_country_when_couple_british? && calculator.partner_british? ) || data_query.ss_marriage_and_partnership?(calculator.ceremony_country) diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 62eb73a4cae..da2bcc74d14 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -612,6 +612,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'same-sex-marriage-country', calculator.same_sex_marriage_country? end end + + context '#same_sex_marriage_country_when_couple_british?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:ss_marriage_countries_when_couple_british?).with('ceremony-country').returns('same-sex-marriage-country-when-couple-british') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'same-sex-marriage-country-when-couple-british', calculator.same_sex_marriage_country_when_couple_british? + end + end end end end From a076dc5a2f5c93f4d4ea72b1ee7bb1645c091f19 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:46:05 +1300 Subject: [PATCH 17/28] Add #same_sex_marriage_and_civil_partnership? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 6 +++++- lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 5e3898d2f19..f5de5a28cee 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -91,7 +91,7 @@ def overseas_passports_embassies def marriage_and_partnership_phrases if same_sex_marriage_country? || same_sex_marriage_country_when_couple_british? 'ss_marriage' - elsif @data_query.ss_marriage_and_partnership?(ceremony_country) + elsif same_sex_marriage_and_civil_partnership? 'ss_marriage_and_partnership' end end @@ -187,5 +187,9 @@ def same_sex_marriage_country? def same_sex_marriage_country_when_couple_british? @data_query.ss_marriage_countries_when_couple_british?(ceremony_country) end + + def same_sex_marriage_and_civil_partnership? + @data_query.ss_marriage_and_partnership?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index b7e093255ae..c54c6606a47 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -243,7 +243,7 @@ def define calculator.same_sex_marriage_country_when_couple_british? && calculator.partner_british? ) || - data_query.ss_marriage_and_partnership?(calculator.ceremony_country) + calculator.same_sex_marriage_and_civil_partnership? :outcome_ss_marriage elsif data_query.cp_equivalent_countries?(calculator.ceremony_country) :outcome_cp_or_equivalent diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index da2bcc74d14..39feae4b0d9 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -623,6 +623,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'same-sex-marriage-country-when-couple-british', calculator.same_sex_marriage_country_when_couple_british? end end + + context '#same_sex_marriage_and_civil_partnership?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:ss_marriage_and_partnership?).with('ceremony-country').returns('same-sex-marriage-and-civil-partnership') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'same-sex-marriage-and-civil-partnership', calculator.same_sex_marriage_and_civil_partnership? + end + end end end end From 810ba2868a61a15132097d158c263181dd905c60 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:54:04 +1300 Subject: [PATCH 18/28] Add #civil_partnership_equivalent_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../outcomes/outcome_cp_or_equivalent.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index f5de5a28cee..89b25e17141 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -191,5 +191,9 @@ def same_sex_marriage_country_when_couple_british? def same_sex_marriage_and_civil_partnership? @data_query.ss_marriage_and_partnership?(ceremony_country) end + + def civil_partnership_equivalent_country? + @data_query.cp_equivalent_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index c54c6606a47..99fce9e3cc6 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -245,7 +245,7 @@ def define ) || calculator.same_sex_marriage_and_civil_partnership? :outcome_ss_marriage - elsif data_query.cp_equivalent_countries?(calculator.ceremony_country) + elsif calculator.civil_partnership_equivalent_country? :outcome_cp_or_equivalent elsif data_query.cp_cni_not_required_countries?(calculator.ceremony_country) :outcome_cp_no_cni diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb index 4650226f641..b12fc1edefc 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb @@ -3,7 +3,7 @@ <% end %> <% content_for :body do %> - <% if data_query.cp_equivalent_countries?(calculator.ceremony_country) %> + <% if calculator.civil_partnership_equivalent_country? %> <%= render partial: 'synonyms_of_cp.govspeak.erb', locals: { calculator: calculator } %> <% end %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 39feae4b0d9..a8b4a8fa95c 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -634,6 +634,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'same-sex-marriage-and-civil-partnership', calculator.same_sex_marriage_and_civil_partnership? end end + + context 'civil_partnership_equivalent_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:cp_equivalent_countries?).with('ceremony-country').returns('civil-partnership-equivalent-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'civil-partnership-equivalent-country', calculator.civil_partnership_equivalent_country? + end + end end end end From 3b882075c71a85a8a98ef0f668f1d881b09f4fea Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 18:58:41 +1300 Subject: [PATCH 19/28] Add #civil_partnership_cni_not_required_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../outcomes/outcome_cp_no_cni.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 89b25e17141..fcdf64934d5 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -195,5 +195,9 @@ def same_sex_marriage_and_civil_partnership? def civil_partnership_equivalent_country? @data_query.cp_equivalent_countries?(ceremony_country) end + + def civil_partnership_cni_not_required_country? + @data_query.cp_cni_not_required_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 99fce9e3cc6..6145c9f7337 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -247,7 +247,7 @@ def define :outcome_ss_marriage elsif calculator.civil_partnership_equivalent_country? :outcome_cp_or_equivalent - elsif data_query.cp_cni_not_required_countries?(calculator.ceremony_country) + elsif calculator.civil_partnership_cni_not_required_country? :outcome_cp_no_cni elsif %w(canada south-africa).include?(calculator.ceremony_country) :outcome_cp_commonwealth_countries diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_no_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_no_cni.govspeak.erb index dcb0e827f5c..f7af972d1e5 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_no_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_no_cni.govspeak.erb @@ -5,7 +5,7 @@ <% content_for :body do %> <% if calculator.ceremony_country == 'usa' %> You can get a same-sex relationship legally recognised in the USA. - <% elsif data_query.cp_cni_not_required_countries?(calculator.ceremony_country) %> + <% elsif calculator.civil_partnership_cni_not_required_country? %> <%= render partial: 'synonyms_of_cp.govspeak.erb', locals: { calculator: calculator } %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index a8b4a8fa95c..07a03c68c57 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -645,6 +645,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'civil-partnership-equivalent-country', calculator.civil_partnership_equivalent_country? end end + + context 'civil_partnership_cni_not_required_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:cp_cni_not_required_countries?).with('ceremony-country').returns('civil-partnership-cni-not-required-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'civil-partnership-cni-not-required-country', calculator.civil_partnership_cni_not_required_country? + end + end end end end From da23c0464da1ec920edaa89de3caf69a699d8ed2 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Wed, 24 Feb 2016 19:03:22 +1300 Subject: [PATCH 20/28] Add #civil_partnership_consular_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ lib/smart_answer_flows/marriage-abroad.rb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index fcdf64934d5..0450e1b71fb 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -199,5 +199,9 @@ def civil_partnership_equivalent_country? def civil_partnership_cni_not_required_country? @data_query.cp_cni_not_required_countries?(ceremony_country) end + + def civil_partnership_consular_country? + @data_query.cp_consular_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 6145c9f7337..06f4adb48d7 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -251,7 +251,7 @@ def define :outcome_cp_no_cni elsif %w(canada south-africa).include?(calculator.ceremony_country) :outcome_cp_commonwealth_countries - elsif data_query.cp_consular_countries?(calculator.ceremony_country) + elsif calculator.civil_partnership_consular_country? :outcome_cp_consular else :outcome_cp_all_other_countries diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 07a03c68c57..ec701b2890f 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -656,6 +656,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'civil-partnership-cni-not-required-country', calculator.civil_partnership_cni_not_required_country? end end + + context 'civil_partnership_consular_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:cp_consular_countries?).with('ceremony-country').returns('civil-partnership-consular-country') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'civil-partnership-consular-country', calculator.civil_partnership_consular_country? + end + end end end end From ddac80a6f1a3fa70ca55834a6252650963c07b68 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:28:36 +1300 Subject: [PATCH 21/28] Add #country_without_consular_facilities? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ .../outcomes/os_affirmation/_fees.govspeak.erb | 2 +- .../outcomes/outcome_cp_or_equivalent.govspeak.erb | 2 +- .../outcomes/outcome_os_affirmation.govspeak.erb | 5 +---- .../outcomes/outcome_os_consular_cni.govspeak.erb | 4 ++-- .../outcomes/outcome_os_no_cni.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 0450e1b71fb..f4682cf2714 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -203,5 +203,9 @@ def civil_partnership_cni_not_required_country? def civil_partnership_consular_country? @data_query.cp_consular_countries?(ceremony_country) end + + def country_without_consular_facilities? + @data_query.countries_without_consular_facilities?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_fees.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_fees.govspeak.erb index 8c13d571f5f..c0ded22e73c 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_fees.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_fees.govspeak.erb @@ -66,7 +66,7 @@ <% end %> -<% unless data_query.countries_without_consular_facilities?(calculator.ceremony_country) %> +<% unless calculator.country_without_consular_facilities? %> <% if calculator.ceremony_country == 'vietnam' %> <%= render partial: 'consular_fees_in_cash_visa_master.govspeak.erb', locals: { calculator: calculator } -%> diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb index b12fc1edefc..30bcdab6fe2 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb @@ -64,7 +64,7 @@ Issuing a CNI or equivalent | £65 <% end %> - <% unless (calculator.ceremony_country == 'czech-republic' || data_query.countries_without_consular_facilities?(calculator.ceremony_country)) %> + <% unless (calculator.ceremony_country == 'czech-republic' || calculator.country_without_consular_facilities?) %> <%= render partial: 'link_to_consular_fees.govspeak.erb', locals: { calculator: calculator } %> <% end %> diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb index 0bb693c3eae..0d7e2186b89 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb @@ -43,9 +43,6 @@ <% end %> <%= render partial: 'os_affirmation/fees.govspeak.erb', - locals: { - data_query: data_query, - calculator: calculator - } -%> + locals: { calculator: calculator } -%> <% end %> diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb index 2dbc0fee6f8..328401f0db1 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb @@ -438,7 +438,7 @@ <%= render partial: 'consular_cni_os_fees_incl_null_osta_oath_consular_letter.govspeak.erb' %> <% end %> - <% unless data_query.countries_without_consular_facilities?(calculator.ceremony_country) || calculator.ceremony_country == 'cote-d-ivoire' %> + <% unless calculator.country_without_consular_facilities? || calculator.ceremony_country == 'cote-d-ivoire' %> <% if %w(kazakhstan kyrgyzstan).include?(calculator.ceremony_country) %> You normally have to pay fees for consular services in the local currency - these are shown in the list of [consular fees for Kazakhstan](/government/publications/kazakhstan-kyrgyzstan-consular-fees). @@ -447,7 +447,7 @@ locals: { calculator: calculator } %> <% end %> <% end %> - <% unless data_query.countries_without_consular_facilities?(calculator.ceremony_country) %> + <% unless calculator.country_without_consular_facilities? %> <% if %w(armenia bosnia-and-herzegovina cambodia iceland latvia slovenia tunisia tajikistan).include?(calculator.ceremony_country) %> <%= render partial: 'pay_in_local_currency_ceremony_country_name.govspeak.erb', diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb index 6308c1d4df2..6896108050e 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb @@ -35,7 +35,7 @@ <%= render partial: 'cni_os_consular_facilities_unavailable.govspeak.erb', locals: { calculator: calculator } %> - <% unless data_query.countries_without_consular_facilities?(calculator.ceremony_country) %> + <% unless calculator.country_without_consular_facilities? %> <%= render partial: 'link_to_consular_fees.govspeak.erb', locals: { calculator: calculator } %> <%= render partial: 'pay_by_cash_or_credit_card_no_cheque.govspeak.erb' %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index ec701b2890f..852b8dfd79d 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -667,6 +667,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'civil-partnership-consular-country', calculator.civil_partnership_consular_country? end end + + context 'country_without_consular_facilities?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:countries_without_consular_facilities?).with('ceremony-country').returns('country-without-consular-facilities') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'country-without-consular-facilities', calculator.country_without_consular_facilities? + end + end end end end From 541a6a2b65035ab03a9506137c4422fc2c1ca89c Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:33:18 +1300 Subject: [PATCH 22/28] Add #opposite_sex_21_days_residency_required? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ .../os_affirmation/_what_you_need_to_do.govspeak.erb | 2 +- .../outcomes/outcome_os_consular_cni.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index f4682cf2714..2a993c0724a 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -207,5 +207,9 @@ def civil_partnership_consular_country? def country_without_consular_facilities? @data_query.countries_without_consular_facilities?(ceremony_country) end + + def opposite_sex_21_days_residency_required? + @data_query.os_21_days_residency_required_countries?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_what_you_need_to_do.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_what_you_need_to_do.govspeak.erb index 8fdfe78ff1c..20d8623001a 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_what_you_need_to_do.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_what_you_need_to_do.govspeak.erb @@ -1,7 +1,7 @@ <% if %w(turkey egypt china).include?(calculator.ceremony_country) %> <%= render partial: 'what_you_need_to_do.govspeak.erb', locals: { calculator: calculator } %> -<% elsif data_query.os_21_days_residency_required_countries?(calculator.ceremony_country) %> +<% elsif calculator.opposite_sex_21_days_residency_required? %> ##What you need to do You need to have been living in <%= calculator.country_name_lowercase_prefix %> for 21 days. diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb index 328401f0db1..38b8821a98e 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb @@ -67,7 +67,7 @@ For non-Islamic marriages, you’ll be asked to provide a certificate of no impediment (CNI) to prove you’re allowed to marry. - <% elsif data_query.os_21_days_residency_required_countries?(calculator.ceremony_country) %> + <% elsif calculator.opposite_sex_21_days_residency_required? %> You need to have been living in the country where you intend to marry for 21 full days. <%= render partial: 'you_will_be_asked_for_cni.govspeak.erb' %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 852b8dfd79d..7194338c268 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -678,6 +678,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'country-without-consular-facilities', calculator.country_without_consular_facilities? end end + + context 'opposite_sex_21_days_residency_required?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:os_21_days_residency_required_countries?).with('ceremony-country').returns('21-days-residency-required') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal '21-days-residency-required', calculator.opposite_sex_21_days_residency_required? + end + end end end end From 1219b58131661faadc139c290d3537eae95cc1ea Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:40:20 +1300 Subject: [PATCH 23/28] Add #ceremony_country_is_dutch_caribbean_island? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. --- .../calculators/marriage_abroad_calculator.rb | 6 +++++- .../outcomes/outcome_os_consular_cni.govspeak.erb | 2 +- .../outcomes/outcome_os_no_cni.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 2a993c0724a..97391ddaaf3 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -115,7 +115,7 @@ def country_name_partner_residence 'British (overseas territories citizen)' elsif ceremony_country_is_french_overseas_territory? 'French' - elsif @data_query.dutch_caribbean_islands?(ceremony_country) + elsif ceremony_country_is_dutch_caribbean_island? 'Dutch' elsif %w(hong-kong macao).include?(ceremony_country) 'Chinese' @@ -211,5 +211,9 @@ def country_without_consular_facilities? def opposite_sex_21_days_residency_required? @data_query.os_21_days_residency_required_countries?(ceremony_country) end + + def ceremony_country_is_dutch_caribbean_island? + @data_query.dutch_caribbean_islands?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb index 38b8821a98e..45dcab9ee5d 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb @@ -11,7 +11,7 @@ <% end %> <% if %(japan).exclude?(calculator.ceremony_country) %> <% if calculator.resident_of_uk? %> - <% if data_query.dutch_caribbean_islands?(calculator.ceremony_country) %> + <% if calculator.ceremony_country_is_dutch_caribbean_island? %> <%= calculator.country_name_uppercase_prefix %> is one of the Dutch Caribbean islands. Contact the [Dutch Embassy in the UK](http://www.netherlands-embassy.org.uk/about/index.php?i=121) before making any plans to find out about local marriage laws, including what documents you’ll need diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb index 6896108050e..20cd26624c8 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb @@ -3,7 +3,7 @@ <% end %> <% content_for :body do %> - <% if data_query.dutch_caribbean_islands?(calculator.ceremony_country) %> + <% if calculator.ceremony_country_is_dutch_caribbean_island? %> <%= render partial: 'country_is_dutch_caribbean_island.govspeak.erb', locals: { calculator: calculator } %> <% if calculator.resident_of_uk? %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 7194338c268..1c899ae169b 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -689,6 +689,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal '21-days-residency-required', calculator.opposite_sex_21_days_residency_required? end end + + context 'ceremony_country_is_dutch_caribbean_island?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:dutch_caribbean_islands?).with('ceremony-country').returns('dutch-caribbean-island') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'dutch-caribbean-island', calculator.ceremony_country_is_dutch_caribbean_island? + end + end end end end From 8f83849d87450357a8028baa5476af531d0b7f38 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:44:22 +1300 Subject: [PATCH 24/28] Add #requires_7_day_notice? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ .../outcomes/outcome_os_consular_cni.govspeak.erb | 2 +- .../outcomes/outcome_os_no_cni.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 97391ddaaf3..62e7639222c 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -215,5 +215,9 @@ def opposite_sex_21_days_residency_required? def ceremony_country_is_dutch_caribbean_island? @data_query.dutch_caribbean_islands?(ceremony_country) end + + def requires_7_day_notice? + @data_query.requires_7_day_notice?(ceremony_country) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb index 45dcab9ee5d..da5362ff457 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb @@ -386,7 +386,7 @@ locals: { calculator: calculator } %> <% end %> - <% elsif data_query.requires_7_day_notice?(calculator.ceremony_country) %> + <% elsif calculator.requires_7_day_notice? %> <%= render partial: 'display_notice_of_marriage_7_days.govspeak.erb', locals: { calculator: calculator } %> diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb index 20cd26624c8..b72938c39db 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb @@ -44,7 +44,7 @@ <%= render partial: 'partner_naturalisation_in_uk.govspeak.erb' %> <% end %> - <% if data_query.requires_7_day_notice?(calculator.ceremony_country) %> + <% if calculator.requires_7_day_notice? %> <%= render partial: 'display_notice_of_marriage_7_days.govspeak.erb', locals: { calculator: calculator } %> diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 1c899ae169b..94d05100e05 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -700,6 +700,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'dutch-caribbean-island', calculator.ceremony_country_is_dutch_caribbean_island? end end + + context 'requires_7_day_notice?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + data_query.stubs(:requires_7_day_notice?).with('ceremony-country').returns('requires-7-day-notice') + calculator = MarriageAbroadCalculator.new(data_query: data_query) + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'requires-7-day-notice', calculator.requires_7_day_notice? + end + end end end end From 0dbd94120ed2a5cc1fbdd569e7e7a8e98b5d397b Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:47:15 +1300 Subject: [PATCH 25/28] Add #same_sex_alt_fees_table_country? I want the `MarriageAbroadCalculator` to encapsulate all the logic required by the flow and views. Delegating to the `MarriageAbroadDataQuery` for this method is a step toward that goal. I'm sure the name of this method can be improved but I'm not 100% sure what it means at the moment, so the renaming will have to wait. --- .../calculators/marriage_abroad_calculator.rb | 4 ++++ .../outcomes/outcome_ss_marriage.govspeak.erb | 2 +- .../calculators/marriage_abroad_calculator_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/smart_answer/calculators/marriage_abroad_calculator.rb b/lib/smart_answer/calculators/marriage_abroad_calculator.rb index 62e7639222c..c1890b7bbd1 100644 --- a/lib/smart_answer/calculators/marriage_abroad_calculator.rb +++ b/lib/smart_answer/calculators/marriage_abroad_calculator.rb @@ -219,5 +219,9 @@ def ceremony_country_is_dutch_caribbean_island? def requires_7_day_notice? @data_query.requires_7_day_notice?(ceremony_country) end + + def same_sex_alt_fees_table_country? + @data_query.ss_alt_fees_table_country?(ceremony_country, self) + end end end diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage.govspeak.erb index 6a5f1f7b15d..49aab6976e3 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage.govspeak.erb @@ -131,7 +131,7 @@ <%= render partial: 'partner_naturalisation_in_uk.govspeak.erb' %> - <% if data_query.ss_alt_fees_table_country?(calculator.ceremony_country, calculator) %> + <% if calculator.same_sex_alt_fees_table_country? %> <% case calculator.marriage_and_partnership_phrases %> <% when 'ss_marriage' %> ##Fees diff --git a/test/unit/calculators/marriage_abroad_calculator_test.rb b/test/unit/calculators/marriage_abroad_calculator_test.rb index 94d05100e05..89a90e750d3 100644 --- a/test/unit/calculators/marriage_abroad_calculator_test.rb +++ b/test/unit/calculators/marriage_abroad_calculator_test.rb @@ -711,6 +711,17 @@ class MarriageAbroadCalculatorTest < ActiveSupport::TestCase assert_equal 'requires-7-day-notice', calculator.requires_7_day_notice? end end + + context 'same_sex_alt_fees_table_country?' do + should 'delegate to the data query' do + data_query = stub.quacks_like(MarriageAbroadDataQuery.new) + calculator = MarriageAbroadCalculator.new(data_query: data_query) + data_query.stubs(:ss_alt_fees_table_country?).with('ceremony-country', calculator).returns('same-sex-alt-fees-table') + calculator.ceremony_country = 'ceremony-country' + + assert_equal 'same-sex-alt-fees-table', calculator.same_sex_alt_fees_table_country? + end + end end end end From cc35a836d65e1a68f92782f085b2744f0ec3af7e Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:48:09 +1300 Subject: [PATCH 26/28] Avoid passing data_query unnecessarily The _what_you_need_to_do partial doesn't use `data_query`. --- .../outcomes/outcome_os_affirmation.govspeak.erb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb index 0d7e2186b89..72f0a2be57e 100644 --- a/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb +++ b/lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb @@ -31,10 +31,7 @@ <% end %> <%= render partial: 'os_affirmation/what_you_need_to_do.govspeak.erb', - locals: { - calculator: calculator, - data_query: data_query - } -%> + locals: { calculator: calculator } -%> <% if calculator.ceremony_country == 'united-arab-emirates' && calculator.resident_of_ceremony_country? %> You may be able to get married at the British Embassy if you’re both resident in the United Arab Emirates and can prove that there are no other suitable facilities to get married locally. From 7fc0decfae27b6182d0b17e4a9adf4dacabf889b Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 19:52:20 +1300 Subject: [PATCH 27/28] Remove data_query from marriage-abroad flow All access of the `MarriageAbroadDataQuery` is now done via the `MarriageAbroadCalculator` so we no longer need to instantiate this `data_query` in the flow. --- lib/smart_answer_flows/marriage-abroad.rb | 44 ++++------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/lib/smart_answer_flows/marriage-abroad.rb b/lib/smart_answer_flows/marriage-abroad.rb index 06f4adb48d7..16c1e6cb336 100644 --- a/lib/smart_answer_flows/marriage-abroad.rb +++ b/lib/smart_answer_flows/marriage-abroad.rb @@ -15,7 +15,6 @@ def define status :published satisfies_need "101000" - data_query = SmartAnswer::Calculators::MarriageAbroadDataQuery.new exclude_countries = %w(holy-see british-antarctic-territory the-occupied-palestinian-territories) # Q1 @@ -331,10 +330,6 @@ def define outcome :outcome_os_italy outcome :outcome_consular_cni_os_residing_in_third_country do - precalculate :data_query do - data_query - end - precalculate :current_path do (['/marriage-abroad/y'] + responses).join('/') end @@ -349,9 +344,6 @@ def define end outcome :outcome_os_consular_cni do - precalculate :data_query do - data_query - end precalculate :three_day_residency_requirement_applies do %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) end @@ -388,40 +380,20 @@ def define end end - outcome :outcome_os_france_or_fot do - precalculate :data_query do - data_query - end - end + outcome :outcome_os_france_or_fot - outcome :outcome_os_affirmation do - precalculate :data_query do - data_query - end - end + outcome :outcome_os_affirmation - outcome :outcome_os_no_cni do - precalculate :data_query do - data_query - end - end + outcome :outcome_os_no_cni outcome :outcome_os_other_countries #CP outcomes - outcome :outcome_cp_or_equivalent do - precalculate :data_query do - data_query - end - end + outcome :outcome_cp_or_equivalent outcome :outcome_cp_france_pacs - outcome :outcome_cp_no_cni do - precalculate :data_query do - data_query - end - end + outcome :outcome_cp_no_cni outcome :outcome_cp_commonwealth_countries @@ -437,11 +409,7 @@ def define outcome :outcome_cp_all_other_countries - outcome :outcome_ss_marriage do - precalculate :data_query do - data_query - end - end + outcome :outcome_ss_marriage outcome :outcome_ss_marriage_not_possible From 021d901510fa76f58588c58a0aa57dc6636885a3 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Mon, 29 Feb 2016 20:36:48 +1300 Subject: [PATCH 28/28] Update checksum data for marriage-abroad All regression tests are passing so I'm happy to update the checksum data. Updated using: $ rails r script/generate-checksums-for-smart-answer.rb \ marriage-abroad --- test/data/marriage-abroad-files.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/data/marriage-abroad-files.yml b/test/data/marriage-abroad-files.yml index ca1a9633c2e..bcf1fc11900 100644 --- a/test/data/marriage-abroad-files.yml +++ b/test/data/marriage-abroad-files.yml @@ -1,5 +1,5 @@ --- -lib/smart_answer_flows/marriage-abroad.rb: 0cb9f0591bd432acc90942a352dbfc1c +lib/smart_answer_flows/marriage-abroad.rb: 4bfc3759306b93273cd92f1c66a64d24 test/data/marriage-abroad-questions-and-responses.yml: 85feca37588fbe9da8d56b382e6cdc23 test/data/marriage-abroad-responses-and-expected-results.yml: e5f779e927f25f4b67316adb9dd54a57 lib/smart_answer_flows/marriage-abroad/marriage_abroad.govspeak.erb: b4d0cfc1c7c4776d968c9b5b6df85027 @@ -91,27 +91,27 @@ lib/smart_answer_flows/marriage-abroad/outcomes/_you_have_been_divorced_or_widow lib/smart_answer_flows/marriage-abroad/outcomes/_you_will_be_asked_for_cni.govspeak.erb: cd1226b515c6a1723da99be2cb207c51 lib/smart_answer_flows/marriage-abroad/outcomes/_you_will_have_to_wait_to_get_married.govspeak.erb: c9fa9fa95d1133789ae786d5b0bb6749 lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_contact.govspeak.erb: 6cc6f30f8f2b076c5ccfc5e865663bc0 -lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_fees.govspeak.erb: c9e67faee14d8acf07a6c897557a012b -lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_what_you_need_to_do.govspeak.erb: 2e671c299f97d75c034e9cded0e03be0 +lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_fees.govspeak.erb: f96329c85727f28d4e4f0be9a1c91c28 +lib/smart_answer_flows/marriage-abroad/outcomes/os_affirmation/_what_you_need_to_do.govspeak.erb: f3b26a16b87e458dec9f089f527061a1 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_brazil_not_living_in_the_uk.govspeak.erb: e3fb0ad81caf8965909db65b7e14603f -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_consular_cni_os_residing_in_third_country.govspeak.erb: 6cea3ad27f4d7caf4861390f7e12145c +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_consular_cni_os_residing_in_third_country.govspeak.erb: 611b13466b903e147bf7c6d4bd9442e2 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_all_other_countries.govspeak.erb: 7e4e34579ba21e10c2a36b0a11241c24 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_commonwealth_countries.govspeak.erb: 19bb1b2a9333666a3cc254bfbc863ee2 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_consular.govspeak.erb: dfcfe85f0ad7068856f039d6d8c3ad81 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_france_pacs.govspeak.erb: 71ed894fbccf1cd2249915ceca553bf4 -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_no_cni.govspeak.erb: 8746892bf4bef152cb87b181d665f9fa -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb: 8be36f8b9db6c014cb652853136c7d13 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_no_cni.govspeak.erb: d016ac758c0f76f20f0fc2de524b7065 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_cp_or_equivalent.govspeak.erb: e4d51f5d3dadf2402e08dabfe8717776 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ireland.govspeak.erb: 5acba40ca6d8af05497706d6a151b605 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_marriage_via_local_authorities.govspeak.erb: 3bae8886bb9b619aa509b7e6fc3dd178 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_monaco.govspeak.erb: ed16ccde85e5b0062e85addad4c21d44 -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb: 81e9ed6ecc33290e700c63108f3625a7 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_affirmation.govspeak.erb: 66aa158650bfb56b8c55ceeca01dd310 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_belarus.govspeak.erb: 692517b079ae0c49fd8b1c0f5b0685bc lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_bot.govspeak.erb: f9ce7bc3d0e5880606bf18b3f9cf1bc9 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_cambodia.govspeak.erb: 5dbe3487ec6513617f2f00ed89b30672 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_colombia.govspeak.erb: a0860f0581acfa1e5533f3114569301c lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_commonwealth.govspeak.erb: 7ed275a2c4647d85076d77ddf3eda685 -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb: 778dfb503a732745584e4efa98b6e213 -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb: 1ba9ed7a52df8b1ce74eb0e32c35e246 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_consular_cni.govspeak.erb: 58baa72cd8735ab8ac8145fce355c3c7 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_france_or_fot.govspeak.erb: 71d74db77499d680423d7586ba9e0e61 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_germany.govspeak.erb: 3f5150acb8ad77d3a5d56909e60a8000 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_hong_kong.govspeak.erb: 9c1686c0a3ba24dff0297e4e04f2fae6 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_indonesia.govspeak.erb: aa8fee3ebe6546671da3f52fb83993db @@ -121,7 +121,7 @@ lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_kosovo.govspeak.erb: lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_kuwait.govspeak.erb: 971c28691e79a8beed0efbb61523b111 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_laos.govspeak.erb: 318a28fe7d6a3f19ac8457e2ada7faf4 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_marriage_impossible_no_laos_locals.govspeak.erb: 23fc1e82a139254773a19515d8cb73b7 -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb: 5e2f61f080d1574a1015fd8f9238c437 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_no_cni.govspeak.erb: 5f136e2925649eb32a8769ada47adb79 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_oman.govspeak.erb: 9e41a0b2ae8699dce5cc3dbe301e049f lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_other_countries.govspeak.erb: 7703cc62823eff217cddb9adb9f61554 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_poland.govspeak.erb: c58d79b7eab27b73359d060352cf9747 @@ -129,7 +129,7 @@ lib/smart_answer_flows/marriage-abroad/outcomes/outcome_os_slovenia.govspeak.erb lib/smart_answer_flows/marriage-abroad/outcomes/outcome_portugal.govspeak.erb: 7928e930761d5d6d2f32491194004c15 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_spain.govspeak.erb: c0679dfee2c3e04b8773fa6117e9df14 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_affirmation.govspeak.erb: 27cf6dd1f2f8602d40f46cb32970d308 -lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage.govspeak.erb: c4e8b0a3d2be85f92d014c05821ba317 +lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage.govspeak.erb: 6c95c2890c40148d8966dc69cbcd7940 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage_malta.govspeak.erb: b7450b569fc6fb92e671ca0dac196ce4 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_ss_marriage_not_possible.govspeak.erb: 2c396fa00b70301c2f3ff952b2b6aee3 lib/smart_answer_flows/marriage-abroad/outcomes/outcome_switzerland.govspeak.erb: 4cf5714aa31b252c55e159b24cd7b657 @@ -138,7 +138,7 @@ lib/smart_answer_flows/marriage-abroad/questions/legal_residency.govspeak.erb: 7 lib/smart_answer_flows/marriage-abroad/questions/marriage_or_pacs.govspeak.erb: a51aecfac697188f90ca9efefcb2e0ea lib/smart_answer_flows/marriage-abroad/questions/partner_opposite_or_same_sex.govspeak.erb: 40d0c99a5be50f0625c6562f06fe4afd lib/smart_answer_flows/marriage-abroad/questions/what_is_your_partners_nationality.govspeak.erb: 80e04f36c75c232bede1a244d621471e -lib/smart_answer/calculators/marriage_abroad_calculator.rb: d5542e5dc4c6455f58919c7fc180428f +lib/smart_answer/calculators/marriage_abroad_calculator.rb: a6a7bcf0ca3c850249e972a752d1a68a lib/smart_answer_flows/shared/_overseas_passports_embassies.govspeak.erb: 2f521bae99c2f48b49d07bcb283a8063 lib/smart_answer/calculators/marriage_abroad_data_query.rb: 80043ce123ab86befc4def86361abb81 lib/smart_answer/calculators/country_name_formatter.rb: 69a0726640385f42de50b80fdb144ff8