diff --git a/app/flows/check_uk_visa_flow.rb b/app/flows/check_uk_visa_flow.rb index 304afc9fc0e..0ab07f59a38 100644 --- a/app/flows/check_uk_visa_flow.rb +++ b/app/flows/check_uk_visa_flow.rb @@ -106,25 +106,13 @@ def define next_node do if calculator.travelling_to_channel_islands_or_isle_of_man? - next question(:channel_islands_or_isle_of_man?) + next question :channel_islands_or_isle_of_man? + elsif calculator.has_passport_requiring_no_visa? + next outcome :outcome_no_visa_needed elsif calculator.travelling_to_ireland? - if (calculator.passport_country_in_non_visa_national_list? || - calculator.passport_country_in_eea? || - calculator.passport_country_in_british_overseas_territories_list?) && - !calculator.travel_document? - next outcome(:outcome_no_visa_needed) - else - next outcome(:outcome_transit_to_the_republic_of_ireland) - end + next outcome :outcome_transit_to_the_republic_of_ireland elsif calculator.travelling_to_elsewhere? - if (calculator.passport_country_in_non_visa_national_list? || - calculator.passport_country_in_eea? || - calculator.passport_country_in_british_overseas_territories_list?) && - !calculator.travel_document? - next outcome(:outcome_no_visa_needed) - else - next question(:passing_through_uk_border_control?) - end + next question :passing_through_uk_border_control? end end end @@ -153,26 +141,21 @@ def define end next_node do - if calculator.passing_through_uk_border_control? - if calculator.passport_country_is_taiwan? - outcome :outcome_transit_taiwan_through_border_control - elsif calculator.passport_country_in_visa_national_list? || - calculator.passport_country_in_electronic_visa_waiver_list? || - calculator.travel_document? - outcome :outcome_transit_leaving_airport - elsif calculator.passport_country_in_direct_airside_transit_visa_list? - outcome :outcome_transit_leaving_airport_direct_airside_transit_visa - end + if calculator.passing_through_uk_border_control? && calculator.passport_country_is_taiwan? + outcome :outcome_transit_taiwan_through_border_control + elsif calculator.passing_through_uk_border_control? && calculator.requires_a_visitor_in_transit_visa? + outcome :outcome_transit_leaving_airport + elsif calculator.passing_through_uk_border_control? && calculator.requires_a_direct_airside_transit_visa? + outcome :outcome_transit_leaving_airport_direct_airside_transit_visa elsif calculator.passport_country_is_taiwan? outcome :outcome_transit_taiwan elsif calculator.passport_country_is_venezuela? outcome :outcome_no_visa_needed elsif calculator.applicant_is_stateless_or_a_refugee? outcome :outcome_transit_refugee_not_leaving_airport - elsif calculator.passport_country_in_direct_airside_transit_visa_list? + elsif calculator.requires_a_direct_airside_transit_visa? outcome :outcome_transit_not_leaving_airport - elsif calculator.passport_country_in_visa_national_list? || - calculator.travel_document? + elsif calculator.no_transit_visa_is_required? outcome :outcome_no_visa_needed end end @@ -188,40 +171,14 @@ def define end next_node do - if calculator.staying_for_over_six_months? - if calculator.study_visit? - outcome :outcome_study_y # outcome 2 study y - elsif calculator.work_visit? - question :what_type_of_work? - end - elsif calculator.staying_for_six_months_or_less? - if calculator.study_visit? - if calculator.passport_country_in_electronic_visa_waiver_list? - outcome :outcome_study_waiver - elsif calculator.passport_country_is_taiwan? - outcome :outcome_study_waiver_taiwan - elsif calculator.passport_country_in_direct_airside_transit_visa_list? || - calculator.passport_country_in_visa_national_list? || - calculator.travel_document? - outcome :outcome_study_m # outcome 3 study m visa needed short courses - elsif calculator.passport_country_in_british_overseas_territories_list? || calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_eea? - outcome :outcome_study_no_visa_needed # outcome 1 no visa needed - end - elsif calculator.work_visit? - if calculator.passport_country_in_electronic_visa_waiver_list? - outcome :outcome_work_waiver - elsif (calculator.passport_country_in_british_overseas_territories_list? || - calculator.passport_country_is_taiwan? || - calculator.passport_country_in_non_visa_national_list? || - calculator.passport_country_in_eea?) && - !calculator.travel_document? - # outcome 5.5 work N no visa needed - outcome :outcome_work_n - else - # outcome 5 work m visa needed short courses - outcome :outcome_work_m - end - end + if calculator.work_visit? && calculator.staying_for_over_six_months? + question :what_type_of_work? + elsif calculator.work_visit? + work_outcome = flow.work_visit_outcome_lambda.call calculator + outcome work_outcome unless work_outcome.nil? + elsif calculator.study_visit? + study_outcome = flow.study_visit_lambda.call calculator + outcome study_outcome unless study_outcome.nil? end end end @@ -339,11 +296,11 @@ def travel_response_next_route(node) end if calculator.school_visit? - if calculator.passport_country_in_electronic_visa_waiver_list? + if calculator.has_passport_requiring_electronic_visa_waiver_list? next outcome(:outcome_school_waiver) elsif calculator.passport_country_is_taiwan? next outcome(:outcome_study_waiver_taiwan) - elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_british_overseas_territories_list? || calculator.passport_country_in_eea? + elsif calculator.has_passport_allowing_school_visits? next outcome(:outcome_school_n) else next outcome(:outcome_school_y) @@ -351,14 +308,11 @@ def travel_response_next_route(node) end if calculator.medical_visit? - if calculator.passport_country_in_electronic_visa_waiver_list? + if calculator.has_passport_requiring_electronic_visa_waiver_list? next outcome(:outcome_visit_waiver) elsif calculator.passport_country_is_taiwan? next outcome(:outcome_visit_waiver_taiwan) - elsif (calculator.passport_country_in_non_visa_national_list? || - calculator.passport_country_in_eea? || - calculator.passport_country_in_british_overseas_territories_list?) && - !calculator.travel_document? + elsif calculator.has_passport_requiring_no_visa? next outcome(:outcome_medical_n) else next outcome(:outcome_medical_y) @@ -366,14 +320,11 @@ def travel_response_next_route(node) end if calculator.tourism_visit? - if calculator.passport_country_in_electronic_visa_waiver_list? + if calculator.has_passport_requiring_electronic_visa_waiver_list? next outcome(:outcome_visit_waiver) elsif calculator.passport_country_is_taiwan? next outcome(:outcome_visit_waiver_taiwan) - elsif (calculator.passport_country_in_non_visa_national_list? || - calculator.passport_country_in_eea? || - calculator.passport_country_in_british_overseas_territories_list?) && - !calculator.travel_document? + elsif calculator.has_passport_requiring_no_visa? next outcome(:outcome_tourism_n) else next question(:travelling_visiting_partner_family_member?) @@ -385,11 +336,11 @@ def travel_response_next_route(node) next outcome(:outcome_marriage_nvn_british_overseas_territories) elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_british_overseas_territories_list? next outcome(:outcome_marriage_nvn_british_overseas_territories) - elsif calculator.passport_country_in_electronic_visa_waiver_list? + elsif calculator.has_passport_requiring_electronic_visa_waiver_list? next outcome(:outcome_marriage_electronic_visa_waiver) elsif calculator.passport_country_is_taiwan? next outcome(:outcome_marriage_taiwan) - elsif calculator.passport_country_in_direct_airside_transit_visa_list? || calculator.passport_country_in_visa_national_list? + elsif calculator.requires_a_direct_airside_transit_visa? || calculator.passport_country_in_visa_national_list? next outcome(:outcome_marriage_visa_nat_direct_airside_transit_visa) end end @@ -407,4 +358,44 @@ def travel_response_next_route(node) end end end + + def study_visit_lambda + lambda { |calculator| + if calculator.staying_for_over_six_months? + return :outcome_study_y # outcome 2 study y + elsif calculator.staying_for_six_months_or_less? && calculator.has_passport_requiring_electronic_visa_waiver_list? + return :outcome_study_waiver + elsif calculator.staying_for_six_months_or_less? && calculator.passport_country_is_taiwan? + return :outcome_study_waiver_taiwan + elsif calculator.staying_for_six_months_or_less? && + (calculator.requires_a_direct_airside_transit_visa? || + calculator.passport_country_in_visa_national_list? || + calculator.travel_document?) + + return :outcome_study_m # outcome 3 study m visa needed short courses + elsif calculator.staying_for_six_months_or_less? && + (calculator.passport_country_in_british_overseas_territories_list? || + calculator.passport_country_in_non_visa_national_list? || + calculator.passport_country_in_eea?) + + return :outcome_study_no_visa_needed # outcome 1 no visa needed + else + return nil + end + } + end + + def work_visit_outcome_lambda + lambda { |calculator| + if calculator.staying_for_six_months_or_less? && calculator.has_passport_requiring_electronic_visa_waiver_list? + return :outcome_work_waiver + elsif calculator.staying_for_six_months_or_less? && calculator.short_work_visits_are_approved? + return :outcome_work_n # outcome 5.5 work N no visa needed + elsif calculator.staying_for_six_months_or_less? + return :outcome_work_m # outcome 5 work m visa needed short courses + else + return nil + end + } + end end diff --git a/app/flows/check_uk_visa_flow/outcomes/outcome_transit_leaving_airport.erb b/app/flows/check_uk_visa_flow/outcomes/outcome_transit_leaving_airport.erb index b9070f035d8..f157f97ced4 100644 --- a/app/flows/check_uk_visa_flow/outcomes/outcome_transit_leaving_airport.erb +++ b/app/flows/check_uk_visa_flow/outcomes/outcome_transit_leaving_airport.erb @@ -1,5 +1,5 @@ <% text_for :title do %> - <% if calculator.passport_country_in_electronic_visa_waiver_list? %> + <% if calculator.has_passport_requiring_electronic_visa_waiver_list? %> You’ll need an electronic visa waiver (EVW) or a Visitor in Transit visa <% else %> You’ll need a visa to pass through the UK in transit @@ -7,7 +7,7 @@ <% end %> <% govspeak_for :body do %> - <% if calculator.passport_country_in_electronic_visa_waiver_list? %> + <% if calculator.has_passport_requiring_electronic_visa_waiver_list? %> You must either apply for: - an [electronic visa waiver](/get-electronic-visa-waiver) diff --git a/app/flows/check_uk_visa_flow/outcomes/outcome_transit_to_the_republic_of_ireland.erb b/app/flows/check_uk_visa_flow/outcomes/outcome_transit_to_the_republic_of_ireland.erb index 415c81e2498..657a2397b6b 100644 --- a/app/flows/check_uk_visa_flow/outcomes/outcome_transit_to_the_republic_of_ireland.erb +++ b/app/flows/check_uk_visa_flow/outcomes/outcome_transit_to_the_republic_of_ireland.erb @@ -1,7 +1,7 @@ <% text_for :title do %> <% if calculator.passport_country_is_taiwan? %> You will not need a visa if your passport has a personal ID number on the bio data page. - <% elsif calculator.passport_country_in_electronic_visa_waiver_list? %> + <% elsif calculator.has_passport_requiring_electronic_visa_waiver_list? %> You’ll need an electronic visa waiver (EVW) or a Standard Visitor visa <% else %> You’ll need a visa to pass through the UK (unless you’re exempt) @@ -16,7 +16,7 @@ [Check what documents you need to bring](/government/publications/visitor-visa-guide-to-supporting-documents) to show officers at the UK border. If your passport does not have a personal ID number on the bio data page you’ll usually need to apply for a [Standard Visitor visa](/standard-visitor). - <% elsif calculator.passport_country_in_electronic_visa_waiver_list? %> + <% elsif calculator.has_passport_requiring_electronic_visa_waiver_list? %> You must either apply for: diff --git a/app/flows/check_uk_visa_flow/questions/channel_islands_or_isle_of_man.erb b/app/flows/check_uk_visa_flow/questions/channel_islands_or_isle_of_man.erb index 7250cb4a595..d617b78fba5 100644 --- a/app/flows/check_uk_visa_flow/questions/channel_islands_or_isle_of_man.erb +++ b/app/flows/check_uk_visa_flow/questions/channel_islands_or_isle_of_man.erb @@ -7,9 +7,9 @@ <% if calculator.passport_country_in_british_overseas_territories_list? || calculator.passport_country_in_non_visa_national_list? %> You might need a UK visa if you don’t have a visa (or a wet ink stamp) for the Channel Islands or the Isle of Man. - <% elsif calculator.passport_country_in_electronic_visa_waiver_list? %> + <% elsif calculator.has_passport_requiring_electronic_visa_waiver_list? %> You’ll need a UK visa or an [Electronic Visa Waiver](/get-electronic-visa-waiver) if you don’t have a visa (or wet ink stamp) for the Channel Islands or the Isle of Man. - <% elsif calculator.passport_country_in_direct_airside_transit_visa_list? || + <% elsif calculator.requires_a_direct_airside_transit_visa? || calculator.passport_country_in_visa_national_list? %> You’ll need a UK visa if you don’t have a visa (or a wet ink stamp) for the Channel Islands or the Isle of Man. <% else %> diff --git a/lib/smart_answer/calculators/uk_visa_calculator.rb b/lib/smart_answer/calculators/uk_visa_calculator.rb index 7486906a5ba..6cef585e8e0 100644 --- a/lib/smart_answer/calculators/uk_visa_calculator.rb +++ b/lib/smart_answer/calculators/uk_visa_calculator.rb @@ -34,10 +34,6 @@ def visas_for_outcome }.compact end - def visa_types_for_outcome - visas_for_outcome.map { |visa| visa["name"] } - end - def number_of_visas_for_outcome @number_of_visas_for_outcome ||= visas_for_outcome.count end @@ -62,7 +58,7 @@ def passport_country_in_british_overseas_territories_list? COUNTRY_GROUP_BRITISH_OVERSEAS_TERRITORIES.include?(@passport_country) end - def passport_country_in_direct_airside_transit_visa_list? + def requires_a_direct_airside_transit_visa? COUNTRY_GROUP_DIRECT_AIRSIDE_TRANSIT_VISA.include?(@passport_country) end @@ -74,7 +70,7 @@ def passport_country_in_uk_ancestry_visa_list? COUNTRY_GROUP_UK_ANCESTRY_VISA.include?(@passport_country) end - def passport_country_in_electronic_visa_waiver_list? + def has_passport_requiring_electronic_visa_waiver_list? COUNTRY_GROUP_ELECTRONIC_VISA_WAIVER.include?(@passport_country) end @@ -206,6 +202,36 @@ def travelling_visiting_partner_family_member? @travelling_visiting_partner_family_member_answer == "yes" end + def short_work_visits_are_approved? + (passport_country_in_british_overseas_territories_list? || + passport_country_is_taiwan? || + passport_country_in_non_visa_national_list? || + passport_country_in_eea?) && + !travel_document? + end + + def has_passport_requiring_no_visa? + (passport_country_in_non_visa_national_list? || + passport_country_in_eea? || + passport_country_in_british_overseas_territories_list?) && + !travel_document? + end + + def no_transit_visa_is_required? + passport_country_in_visa_national_list? || + travel_document? + end + + def requires_a_visitor_in_transit_visa? + passport_country_in_visa_national_list? || + has_passport_requiring_electronic_visa_waiver_list? || + travel_document? + end + + def has_passport_allowing_school_visits? + passport_country_in_non_visa_national_list? || passport_country_in_british_overseas_territories_list? || passport_country_in_eea? + end + def study_or_work if study_visit? "study" diff --git a/test/unit/calculators/uk_visa_calculator_test.rb b/test/unit/calculators/uk_visa_calculator_test.rb index db8128a0bee..174fd68ce7e 100644 --- a/test/unit/calculators/uk_visa_calculator_test.rb +++ b/test/unit/calculators/uk_visa_calculator_test.rb @@ -63,167 +63,13 @@ class UkVisaCalculatorTest < ActiveSupport::TestCase should "return true if passport_country is in list of countries requiring a direct airside transit visa" do calculator = UkVisaCalculator.new calculator.passport_country = "afghanistan" - assert calculator.passport_country_in_direct_airside_transit_visa_list? + assert calculator.requires_a_direct_airside_transit_visa? end should "return false if passport_country is not in list of countries requiring a direct airside transit visa" do calculator = UkVisaCalculator.new calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_in_direct_airside_transit_visa_list? - end - end - - context "#tourism_visit?" do - should 'return true if purpose_of_visit_answer is "tourism"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "tourism" - assert calculator.tourism_visit? - end - - should 'return false if purpose_of_visit_answer is not "tourism"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-tourism" - assert_not calculator.tourism_visit? - end - end - - context "#work_visit?" do - should 'return true if purpose_of_visit_answer is "work"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "work" - assert calculator.work_visit? - end - - should 'return false if purpose_of_visit_answer is not "work"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-work" - assert_not calculator.work_visit? - end - end - - context "#study_visit?" do - should 'return true if purpose_of_visit_answer is "study"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "study" - assert calculator.study_visit? - end - - should 'return false if purpose_of_visit_answer is not "study"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-study" - assert_not calculator.study_visit? - end - end - - context "#transit_visit?" do - should 'return true if purpose_of_visit_answer is "transit"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "transit" - assert calculator.transit_visit? - end - - should 'return false if purpose_of_visit_answer is not "transit"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-transit" - assert_not calculator.transit_visit? - end - end - - context "#family_visit?" do - should 'return true if purpose_of_visit_answer is "family"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "family" - assert calculator.family_visit? - end - - should 'return false if purpose_of_visit_answer is not "family"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-family" - assert_not calculator.family_visit? - end - end - - context "#marriage_visit?" do - should 'return true if purpose_of_visit_answer is "marriage"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "marriage" - assert calculator.marriage_visit? - end - - should 'return false if purpose_of_visit_answer is not "marriage"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-marriage" - assert_not calculator.marriage_visit? - end - end - - context "#school_visit?" do - should 'return true if purpose_of_visit_answer is "school"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "school" - assert calculator.school_visit? - end - - should 'return false if purpose_of_visit_answer is not "school"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-school" - assert_not calculator.school_visit? - end - end - - context "#medical_visit?" do - should 'return true if purpose_of_visit_answer is "medical"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "medical" - assert calculator.medical_visit? - end - - should 'return false if purpose_of_visit_answer is not "medical"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-medical" - assert_not calculator.medical_visit? - end - end - - context "#diplomatic_visit?" do - should 'return true if purpose_of_visit_answer is "diplomatic"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "diplomatic" - assert calculator.diplomatic_visit? - end - - should 'return false if purpose_of_visit_answer is not "diplomatic"' do - calculator = UkVisaCalculator.new - calculator.purpose_of_visit_answer = "not-diplomatic" - assert_not calculator.diplomatic_visit? - end - end - - context "#passport_country_in_youth_mobility_scheme_list?" do - should "return true if passport_country is in list of youth mobility scheme countries" do - calculator = UkVisaCalculator.new - calculator.passport_country = "australia" - assert calculator.passport_country_in_youth_mobility_scheme_list? - end - - should "return false if passport_country is not in list of youth mobility scheme countries" do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_in_youth_mobility_scheme_list? - end - end - - context "#passport_country_in_uk_ancestry_visa_list?" do - should "return true if passport_country is in list of UK Ancestry Visa countries" do - calculator = UkVisaCalculator.new - calculator.passport_country = "australia" - assert calculator.passport_country_in_youth_mobility_scheme_list? - end - - should "return false if passport_country is not in list of UK Ancestry Visa countries" do - calculator = UkVisaCalculator.new - calculator.passport_country = "slovenia" - assert_not calculator.passport_country_in_youth_mobility_scheme_list? + assert_not calculator.requires_a_direct_airside_transit_visa? end end @@ -231,13 +77,13 @@ class UkVisaCalculatorTest < ActiveSupport::TestCase should "return true if passport_country is in list of countries that can apply for an electronic visa waiver" do calculator = UkVisaCalculator.new calculator.passport_country = "oman" - assert calculator.passport_country_in_electronic_visa_waiver_list? + assert calculator.has_passport_requiring_electronic_visa_waiver_list? end should "return false if passport_country is not in list of countries that can apply for an electronic visa waiver" do calculator = UkVisaCalculator.new calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_in_electronic_visa_waiver_list? + assert_not calculator.has_passport_requiring_electronic_visa_waiver_list? end end @@ -283,104 +129,6 @@ class UkVisaCalculatorTest < ActiveSupport::TestCase end end - context "#passport_country_in_b1_b2_visa_exception_list?" do - should "return true if passport_country is in list of countries to which the b1/b2 visa exception applies" do - calculator = UkVisaCalculator.new - calculator.passport_country = "syria" - assert calculator.passport_country_in_b1_b2_visa_exception_list? - end - - should "return false if passport_country is not in list of countries to which the b1/b2 visa exception applies" do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_in_b1_b2_visa_exception_list? - end - end - - context "#passport_country_is_israel?" do - should 'return true if passport_country is "israel"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "israel" - assert calculator.passport_country_is_israel? - end - - should 'return false if passport_country is not "israel"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_is_israel? - end - end - - context "#passport_country_is_taiwan?" do - should 'return true if passport_country is "taiwan"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "taiwan" - assert calculator.passport_country_is_taiwan? - end - - should 'return false if passport_country is not "taiwan"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_is_taiwan? - end - end - - context "#passport_country_is_venezuela?" do - should 'return true if passport_country is "venezuela"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "venezuela" - assert calculator.passport_country_is_venezuela? - end - - should 'return false if passport_country is not "venezuela"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_is_venezuela? - end - end - - context "#passport_country_is_croatia?" do - should 'return true if passport_country is "croatia"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "croatia" - assert calculator.passport_country_is_croatia? - end - - should 'return false if passport_country is not "croatia"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_is_croatia? - end - end - - context "#passport_country_is_china?" do - should 'return true if passport_country is "china"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "china" - assert calculator.passport_country_is_china? - end - - should 'return false if passport_country is not "china"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_is_china? - end - end - - context "#passport_country_is_turkey?" do - should 'return true if passport_country is "turkey"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "turkey" - assert calculator.passport_country_is_turkey? - end - - should 'return false if passport_country is not "turkey"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "made-up-country" - assert_not calculator.passport_country_is_turkey? - end - end - context "#passport_country_is_estonia?" do should "return true if passport_country is Estonia" do calculator = UkVisaCalculator.new @@ -394,45 +142,13 @@ class UkVisaCalculatorTest < ActiveSupport::TestCase assert_not calculator.passport_country_is_estonia? end - should "return true of user has an alien passport" do + should "return true if user has an alien passport" do calculator = UkVisaCalculator.new calculator.passport_country = "estonia-alien-passport" assert calculator.passport_country_is_estonia? end end - context "#passport_country_is_hong_kong?" do - should 'return true if passport_country is "hong-kong"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "hong-kong" - assert calculator.passport_country_is_hong_kong? - end - - should 'return false if passport_country is not "hong-kong"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "not-hong-kong" - assert_not calculator.passport_country_is_hong_kong? - - calculator = UkVisaCalculator.new - calculator.passport_country = "hong-kong-(british-national-overseas)" - assert_not calculator.passport_country_is_hong_kong? - end - end - - context "#passport_country_is_ireland?" do - should 'return true if passport_country is "ireland"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "ireland" - assert calculator.passport_country_is_ireland? - end - - should 'return false if passport_country is not "ireland"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "not-ireland" - assert_not calculator.passport_country_is_ireland? - end - end - context "#passport_country_is_latvia?" do should "return true if passport_country is Latvia" do calculator = UkVisaCalculator.new @@ -453,117 +169,7 @@ class UkVisaCalculatorTest < ActiveSupport::TestCase end end - context "#passport_country_is_macao?" do - should 'return true if passport_country is "macao"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "macao" - assert calculator.passport_country_is_macao? - end - - should 'return false if passport_country is not "macao"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "not-macao" - assert_not calculator.passport_country_is_macao? - end - end - - context "#applicant_is_stateless_or_a_refugee?" do - should 'return true if passport_country is "stateless-or-refugee"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "stateless-or-refugee" - assert calculator.applicant_is_stateless_or_a_refugee? - end - - should 'return false if passport_country is not "stateless-or-refugee"' do - calculator = UkVisaCalculator.new - calculator.passport_country = "not-stateless-or-refugee" - assert_not calculator.applicant_is_stateless_or_a_refugee? - end - end - - context "#passing_through_uk_border_control?" do - should 'return true if passing_through_uk_border_control_answer is "yes"' do - calculator = UkVisaCalculator.new - calculator.passing_through_uk_border_control_answer = "yes" - assert calculator.passing_through_uk_border_control? - end - - should 'return false if passing_through_uk_border_control_answer is "no"' do - calculator = UkVisaCalculator.new - calculator.passing_through_uk_border_control_answer = "no" - assert_not calculator.passing_through_uk_border_control? - end - end - context "#travelling_to_cta?" do - context "#travelling_to_channel_islands_or_isle_of_man?" do - should 'return true if travelling_to_cta_answer is "channel_islands_or_isle_of_man"' do - calculator = UkVisaCalculator.new - calculator.travelling_to_cta_answer = "channel_islands_or_isle_of_man" - assert calculator.travelling_to_channel_islands_or_isle_of_man? - end - - should 'return false if travelling_to_cta_answer is not equal to "channel_islands_or_isle_of_man"' do - calculator = UkVisaCalculator.new - calculator.travelling_to_cta_answer = "something_else" - assert_not calculator.travelling_to_channel_islands_or_isle_of_man? - end - end - - context "#travelling_to_ireland?" do - should 'return true if travelling_to_cta_answer is "republic_of_ireland"' do - calculator = UkVisaCalculator.new - calculator.travelling_to_cta_answer = "republic_of_ireland" - assert calculator.travelling_to_ireland? - end - - should 'return false if travelling_to_cta_answer is "republic_of_ireland"' do - calculator = UkVisaCalculator.new - calculator.travelling_to_cta_answer = "something_else" - assert_not calculator.travelling_to_ireland? - end - end - - context "#travelling_to_elsewhere?" do - should 'return true if travelling_to_cta_answer is "somewhere_else"' do - calculator = UkVisaCalculator.new - calculator.travelling_to_cta_answer = "somewhere_else" - assert calculator.travelling_to_elsewhere? - end - - should 'return false if travelling_to_cta_answer is "somewhere_else"' do - calculator = UkVisaCalculator.new - calculator.travelling_to_cta_answer = "something_else" - assert_not calculator.travelling_to_elsewhere? - end - end - - context "#staying_for_over_six_months?" do - should "return true if the applicant is staying for over 6 months" do - calculator = UkVisaCalculator.new - calculator.length_of_stay = "longer_than_six_months" - assert calculator.staying_for_over_six_months? - end - should "return false if the applicant is staying for less than 6 months" do - calculator = UkVisaCalculator.new - calculator.length_of_stay = "six_months_or_less" - assert_not calculator.staying_for_over_six_months? - end - end - - context "#staying_for_six_months_or_less?" do - should "return true if the applicant is staying for 6 months or less" do - calculator = UkVisaCalculator.new - calculator.length_of_stay = "six_months_or_less" - assert calculator.staying_for_six_months_or_less? - end - should "return false if the applicant is staying for more than 6 months" do - calculator = UkVisaCalculator.new - calculator.length_of_stay = "longer_than_six_months" - assert_not calculator.staying_for_six_months_or_less? - end - end - context "eligible_for_india_young_professionals_scheme?" do %w[health digital academic arts religious business other].each do |work_type| should "return true if passport country is India, visiting for work, staying for over six months and type of work is #{work_type}" do