From b0ca41d3a3aecb96c0bb9ba166188447adfce64e Mon Sep 17 00:00:00 2001 From: erikse Date: Thu, 17 Mar 2016 15:52:48 +0000 Subject: [PATCH] Revert "Refactor overseas passports flow updates" --- .../overseas_passports_calculator.rb | 191 ------ .../passport_and_embassy_data_query.rb | 19 + lib/smart_answer_flows/overseas-passports.rb | 175 +++-- .../outcomes/_cost.govspeak.erb | 34 +- .../_getting_your_passport.govspeak.erb | 40 +- .../outcomes/_how_long.govspeak.erb | 2 +- .../outcomes/_how_to_apply.govspeak.erb | 12 +- .../_making_your_application.govspeak.erb | 142 ++-- .../_sending_your_application.govspeak.erb | 32 - ...apply_in_neighbouring_country.govspeak.erb | 4 +- .../outcomes/cannot_apply.govspeak.erb | 2 +- .../_child_or_adult_passport.govspeak.erb | 8 +- .../cost/_payment_instructions.govspeak.erb | 2 +- .../_by_current_location.govspeak.erb | 2 +- .../_by_ips_number.govspeak.erb | 2 +- .../ips_application_result.govspeak.erb | 49 +- ...ips_application_result_online.govspeak.erb | 24 +- .../_book_appointment_online.govspeak.erb | 2 +- .../_send_application_address.govspeak.erb | 2 +- .../_send_application_ips.govspeak.erb | 2 +- test/data/overseas-passports-files.yml | 37 +- .../overseas_passports_test.rb | 32 +- .../overseas_passports_calculator_test.rb | 634 ------------------ .../passport_and_embassy_data_query_test.rb | 11 + 24 files changed, 405 insertions(+), 1055 deletions(-) delete mode 100644 lib/smart_answer/calculators/overseas_passports_calculator.rb delete mode 100644 lib/smart_answer_flows/overseas-passports/outcomes/_sending_your_application.govspeak.erb delete mode 100644 test/unit/calculators/overseas_passports_calculator_test.rb diff --git a/lib/smart_answer/calculators/overseas_passports_calculator.rb b/lib/smart_answer/calculators/overseas_passports_calculator.rb deleted file mode 100644 index 68fe6db2ea8..00000000000 --- a/lib/smart_answer/calculators/overseas_passports_calculator.rb +++ /dev/null @@ -1,191 +0,0 @@ -module SmartAnswer::Calculators - class OverseasPassportsCalculator - APPLY_IN_NEIGHBOURING_COUNTRIES = %w( - british-indian-ocean-territory north-korea south-georgia-and-south-sandwich-islands - ) - - BOOK_APPOINTMENT_ONLINE_COUNTRIES = %w( - kyrgyzstan tajikistan turkmenistan uzbekistan - ) - - UK_VISA_APPLICATION_CENTRE_COUNTRIES = %w( - afghanistan algeria azerbaijan bangladesh belarus burundi burma cambodia - china gaza georgia india indonesia kazakhstan kyrgyzstan laos lebanon - mauritania morocco nepal pakistan russia tajikistan thailand turkmenistan - ukraine uzbekistan western-sahara vietnam venezuela - ) - - UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES = %w( - afghanistan azerbaijan algeria bangladesh belarus burma cambodia china - georgia india indonesia kazakhstan laos lebanon mauritania morocco nepal - pakistan tajikistan thailand turkmenistan ukraine uzbekistan russia - vietnam venezuela western-sahara - ) - - EXCLUDE_COUNTRIES = %w( - holy-see british-antarctic-territory - ) - - INELIGIBLE_COUNTRIES = %w( - iran libya syria yemen - ) - - IPS_APPLICATION_TYPES = %w( - ips_application_1 - ips_application_2 - ips_application_3 - ) - - NON_UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES = %w( - burma cuba sudan tajikistan turkmenistan uzbekistan - ) - - attr_accessor :current_location - attr_accessor :birth_location - attr_accessor :application_action - attr_accessor :child_or_adult - - def initialize(data_query: nil) - @data_query = data_query || PassportAndEmbassyDataQuery.new - end - - def book_appointment_online? - BOOK_APPOINTMENT_ONLINE_COUNTRIES.include?(current_location) - end - - def uk_visa_application_centre? - UK_VISA_APPLICATION_CENTRE_COUNTRIES.include?(current_location) - end - - def uk_visa_application_with_colour_pictures? - UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES.include?(current_location) - end - - def non_uk_visa_application_with_colour_pictures? - NON_UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES.include?(current_location) - end - - def ineligible_country? - INELIGIBLE_COUNTRIES.include?(current_location) - end - - def apply_in_neighbouring_countries? - APPLY_IN_NEIGHBOURING_COUNTRIES.include?(current_location) - end - - def alternate_embassy_location(location = current_location) - PassportAndEmbassyDataQuery::ALT_EMBASSIES[location] - end - - def world_location(location = current_location) - search_location = alternate_embassy_location(location) || location - - WorldLocation.find(search_location) - end - - def world_location_name(location = current_location) - world_location(location).name - end - - def fco_organisation(location = current_location) - world_location(location).fco_organisation - end - - def cash_only_country? - @data_query.cash_only_countries?(current_location) - end - - def renewing_country? - @data_query.renewing_countries?(current_location) - end - - def renewing_new? - application_action == 'renewing_new' - end - - def renewing_old? - application_action == 'renewing_old' - end - - def applying? - application_action == 'applying' - end - - def replacing? - application_action == 'replacing' - end - - def overseas_passports_embassies(location = current_location) - organisation = fco_organisation(location) - organisation ? organisation.offices_with_service('Overseas Passports Service') : [] - end - - def general_action - application_action =~ /^renewing_/ ? 'renewing' : application_action - end - - def passport_data(location = current_location) - @data_query.find_passport_data(location) - end - - def application_type - data = passport_data - data ? data['type'] : nil - end - - def application_form - data = passport_data - data ? data['app_form'] : nil - end - - def application_group(location) - data = passport_data(location) - data ? data['group'] : nil - end - - def optimistic_processing_time - data = passport_data - data ? data['optimistic_processing_time?'] : nil # pretty weird hash key - end - - def application_address - data = passport_data - data ? data['address'] : nil - end - - def waiting_time - data = passport_data - data ? data[application_action] : nil - end - - def supporting_documents - if birth_location.blank? || birth_location == 'united_kingdom' - application_group(current_location) - else - application_group(birth_location) - end - end - - def ips_application? - IPS_APPLICATION_TYPES.include?(application_type) - end - - def ips_online_application? - data = passport_data - data && data['online_application'] - end - - def application_office? - data = passport_data - data && data['application_office'] - end - - def ips_number - application_type.split("_")[2] if ips_application? - end - - def ips_docs_number - supporting_documents.split("_")[3] if ips_application? - end - end -end diff --git a/lib/smart_answer/calculators/passport_and_embassy_data_query.rb b/lib/smart_answer/calculators/passport_and_embassy_data_query.rb index 8998497f23d..5df5c568637 100644 --- a/lib/smart_answer/calculators/passport_and_embassy_data_query.rb +++ b/lib/smart_answer/calculators/passport_and_embassy_data_query.rb @@ -7,6 +7,14 @@ class PassportAndEmbassyDataQuery 'guinea' => 'ghana' } + PASSPORT_COSTS = { + 'Australian Dollars' => [[282.21], [325.81], [205.81]], + 'Euros' => [[161, 186], [195, 220], [103, 128]], + 'New Zealand Dollars' => [["317.80", 337.69], ["371.80", 391.69], ["222.80", 242.69]], + 'SLL' => [[900000, 1135000], [1085000, 1320000], [575000, 810000]], + 'South African Rand' => [[2112, 2440], [2549, 2877], [1345, 1673]] + } + CASH_ONLY_COUNTRIES = %w(cuba sudan) RENEWING_COUNTRIES = %w(belarus burma cuba lebanon libya russia sudan tajikistan tunisia turkmenistan uzbekistan zimbabwe) @@ -29,6 +37,17 @@ def renewing_countries?(country_slug) RENEWING_COUNTRIES.include?(country_slug) end + def passport_costs + {}.tap do |costs| + PASSPORT_COSTS.each do |k, v| + [:adult_32, :adult_48, :child].each_with_index do |t, i| + key = "#{k.downcase.gsub(' ', '_')}_#{t}" + costs[key] = v[i].map { |c| "#{number_with_delimiter(c)} #{k}"}.join(" | ") + end + end + end + end + def self.passport_data @passport_data ||= YAML.load_file(Rails.root.join("lib", "data", "passport_data.yml")) end diff --git a/lib/smart_answer_flows/overseas-passports.rb b/lib/smart_answer_flows/overseas-passports.rb index 3350515f70e..045ec90dbd2 100644 --- a/lib/smart_answer_flows/overseas-passports.rb +++ b/lib/smart_answer_flows/overseas-passports.rb @@ -6,28 +6,47 @@ def define status :published satisfies_need "100131" + data_query = Calculators::PassportAndEmbassyDataQuery.new + + exclude_countries = %w(holy-see british-antarctic-territory) + # Q1 - country_select :which_country_are_you_in?, exclude_countries: Calculators::OverseasPassportsCalculator::EXCLUDE_COUNTRIES do - next_node_calculation :calculator do - Calculators::OverseasPassportsCalculator.new + country_select :which_country_are_you_in?, exclude_countries: exclude_countries do + save_input_as :current_location + + calculate :location do + loc = WorldLocation.find(current_location) + if Calculators::PassportAndEmbassyDataQuery::ALT_EMBASSIES.has_key?(current_location) + loc = WorldLocation.find(Calculators::PassportAndEmbassyDataQuery::ALT_EMBASSIES[current_location]) + end + raise InvalidResponse unless loc + loc end - validate do |response| - calculator.world_location(response) + calculate :birth_location do + nil + end + calculate :embassy_address do + nil + end + calculate :send_colour_photocopy_bulletpoint do + nil end - calculate :overseas_passports_embassies do |response| - calculator.overseas_passports_embassies(response) + next_node_calculation :ineligible_country do |response| + %w{iran libya syria yemen}.include?(response) end - next_node(permitted: :auto) do |response| - calculator.current_location = response + next_node_calculation :apply_in_neighbouring_countries do |response| + %w(british-indian-ocean-territory north-korea south-georgia-and-south-sandwich-islands).include?(response) + end - if calculator.ineligible_country? + next_node(permitted: :auto) do |response| + if ineligible_country outcome :cannot_apply elsif response == 'the-occupied-palestinian-territories' question :which_opt? - elsif calculator.apply_in_neighbouring_countries? + elsif apply_in_neighbouring_countries outcome :apply_in_neighbouring_country else question :renewing_replacing_applying? @@ -40,14 +59,8 @@ def define option :gaza option :"jerusalem-or-westbank" - permitted_next_nodes = [ - :renewing_replacing_applying? - ] - next_node(permitted: permitted_next_nodes) do |response| - calculator.current_location = response - - :renewing_replacing_applying? - end + save_input_as :current_location + next_node :renewing_replacing_applying? end # Q2 @@ -57,14 +70,72 @@ def define option :applying option :replacing - permitted_next_nodes = [ - :child_or_adult_passport? - ] - next_node(permitted: permitted_next_nodes) do |response| - calculator.application_action = response + save_input_as :application_action + + precalculate :organisation do + location.fco_organisation + end + + calculate :overseas_passports_embassies do + if organisation + organisation.offices_with_service 'Overseas Passports Service' + else + [] + end + end + + calculate :general_action do |response| + response =~ /^renewing_/ ? 'renewing' : response + end + + calculate :passport_data do + data_query.find_passport_data(current_location) + end + calculate :application_type do + passport_data['type'] + end + calculate :is_ips_application do + %w{ips_application_1 ips_application_2 ips_application_3}.include?(application_type) + end + calculate :ips_number do + application_type.split("_")[2] if is_ips_application + end + + calculate :application_form do + passport_data['app_form'] + end + + calculate :supporting_documents do + passport_data['group'] + end + + calculate :application_address do + passport_data['address'] + end + + calculate :ips_docs_number do + supporting_documents.split("_")[3] if is_ips_application + end + + calculate :ips_result_type do + passport_data['online_application'] ? :ips_application_result_online : :ips_application_result + end + + data_query.passport_costs.each do |k, v| + calculate "costs_#{k}".to_sym do + v + end + end - :child_or_adult_passport? + calculate :waiting_time do + passport_data[application_action] end + + calculate :optimistic_processing_time do + passport_data['optimistic_processing_time?'] + end + + next_node :child_or_adult_passport? end # Q3 @@ -72,13 +143,13 @@ def define option :adult option :child - next_node(permitted: :auto) do - calculator.child_or_adult = response + save_input_as :child_or_adult - if calculator.ips_application? - if calculator.applying? || calculator.renewing_old? + next_node(permitted: :auto) do + if is_ips_application + if %w(applying renewing_old).include?(application_action) question :country_of_birth? - elsif calculator.ips_online_application? + elsif ips_result_type == :ips_application_result_online outcome :ips_application_result_online else outcome :ips_application_result @@ -88,12 +159,24 @@ def define end # Q4 - country_select :country_of_birth?, include_uk: true, exclude_countries: Calculators::OverseasPassportsCalculator::EXCLUDE_COUNTRIES do - next_node(permitted: :auto) do - calculator.birth_location = response + country_select :country_of_birth?, include_uk: true, exclude_countries: exclude_countries do + save_input_as :birth_location - if calculator.ips_application? - if calculator.ips_online_application? + calculate :application_group do |response| + data_query.find_passport_data(response)['group'] + end + + calculate :supporting_documents do |response| + response == 'united-kingdom' ? supporting_documents : application_group + end + + calculate :ips_docs_number do + supporting_documents.split("_")[3] + end + + next_node(permitted: :auto) do + if is_ips_application + if ips_result_type == :ips_application_result_online outcome :ips_application_result_online else outcome :ips_application_result @@ -103,15 +186,31 @@ def define end ## Online IPS Application Result - outcome :ips_application_result_online + outcome :ips_application_result_online do + precalculate :birth_location do + birth_location + end + end ## IPS Application Result - outcome :ips_application_result + outcome :ips_application_result do + precalculate :data_query do + data_query + end + + precalculate :birth_location do + birth_location + end + end ## No-op outcome. outcome :cannot_apply - outcome :apply_in_neighbouring_country + outcome :apply_in_neighbouring_country do + precalculate :title_output do + location.name + end + end end end end diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb index 05377474899..7200e577836 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb @@ -1,9 +1,9 @@ ## Cost -<% if %w(st-helena-ascension-and-tristan-da-cunha).include?(calculator.current_location) %> +<% if %w(st-helena-ascension-and-tristan-da-cunha).include?(current_location) %> You’ll have to pay a fee for your passport. - <% case calculator.child_or_adult %> + <% case child_or_adult %> <% when 'adult' %> | Passport type | Passport fee | |---------------|--------------| @@ -16,10 +16,10 @@ <% end %> You must pay in cash. In addition to the passport fee you’ll need to pay any local administration fees which apply from the office where you make your application. -<% elsif calculator.replacing? and calculator.ips_number == '1' and calculator.ips_docs_number == '1' %> +<% elsif application_action == 'replacing' and ips_number == '1' and ips_docs_number == '1' %> You’ll have to pay a fee for your passport and a courier fee of £9.70. The courier fee pays for your passport to be sent back to you securely. - <% case calculator.child_or_adult %> + <% case child_or_adult %> <% when 'adult' %> | Passport type | Passport fee | Total to pay (including courier fee) | |---------------|--------------|--------------------------------------| @@ -31,10 +31,10 @@ | Child passport | £53.00 | £62.70 | <% end %> - <%= render partial: 'cost/payment_instructions.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'cost/payment_instructions.govspeak.erb', locals: { ips_number: ips_number } %> -<% elsif %w(tajikistan turkmenistan uzbekistan).include?(calculator.current_location) %> - <% case calculator.current_location %> +<% elsif %w(tajikistan turkmenistan uzbekistan).include?(current_location) %> + <% case current_location %> <% when 'tajikistan' %> You’ll have to pay a fee for your passport and a courier fee of £23.01. @@ -49,24 +49,24 @@ The courier fee pays for your passport to be sent securely to the British Embassy in Tashkent for you to collect. <% end %> - <%= render partial: 'cost/child_or_adult_passport.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'cost/child_or_adult_passport.govspeak.erb', locals: { ips_number: ips_number, child_or_adult: child_or_adult } %> - <%= render partial: 'cost/payment_instructions.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'cost/payment_instructions.govspeak.erb', locals: { ips_number: ips_number } %> <% else %> <% uk_visa_application_centre_countries = %w(afghanistan algeria azerbaijan bangladesh belarus burma cambodia china georgia india indonesia kazakhstan laos lebanon mauritania morocco nepal pakistan russia thailand ukraine venezuela vietnam western-sahara) %> <% pay_at_appointment_countries = %w(venezuela) %> - <% if uk_visa_application_centre_countries.include?(calculator.current_location) %> - <% case calculator.ips_number %> + <% if uk_visa_application_centre_countries.include?(current_location) %> + <% case ips_number %> <% when '2' %> You’ll have to pay a fee for your passport and a courier fee of £24.72. The courier fee pays for your passport to be sent securely to the UK Visa Application Centre where you applied for you to collect. <% when '3' %> You’ll have to pay a fee for your passport and a courier fee of £23.01. The courier fee pays for your passport to be sent securely to the UK Visa Application Centre where you applied for you to collect. <% end %> - <% elsif %w(pitcairn-island).include?(calculator.current_location) %> + <% elsif %w(pitcairn-island).include?(current_location) %> You’ll have to pay a fee for your passport and a courier fee of £23.01. The courier fee pays for your passport and supporting documents to be sent back to you securely via the Pitcairn Islands Office in Auckland. <% else %> - <% case calculator.ips_number %> + <% case ips_number %> <% when '1' %> You’ll have to pay a fee for your passport and a courier fee of £19.86. The courier fee pays for your passport and supporting documents to be sent back to you securely. <% when '2' %> @@ -76,13 +76,13 @@ <% end %> <% end %> - <%= render partial: 'cost/child_or_adult_passport.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'cost/child_or_adult_passport.govspeak.erb', locals: { ips_number: ips_number, child_or_adult: child_or_adult } %> - <% if calculator.cash_only_country? %> + <% if data_query.cash_only_countries?(current_location) %> You must pay in cash using local currency - the prices above will be converted according to the exchange rate when you apply. - <% elsif pay_at_appointment_countries.include?(calculator.current_location) %> + <% elsif pay_at_appointment_countries.include?(current_location) %> You must pay at your scheduled appointment using a debit or credit card. American Express, Diner’s Club and Discovery cards aren’t accepted. <% else %> - <%= render partial: 'cost/payment_instructions.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'cost/payment_instructions.govspeak.erb', locals: { ips_number: ips_number } %> <% end %> <% end %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/_getting_your_passport.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/_getting_your_passport.govspeak.erb index 51852f64030..eea8104c174 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/_getting_your_passport.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/_getting_your_passport.govspeak.erb @@ -9,21 +9,21 @@ <% passport_delivered_by_courier_countries = %w(laos) %> <% named_embassy_countries = %w(tajikistan turkmenistan uzbekistan) %> -<% if passport_delivered_by_courier_countries.include?(calculator.current_location) %> +<% if passport_delivered_by_courier_countries.include?(current_location) %> Your passport will be delivered to you by courier. -<% elsif uk_visa_application_centre_countries.include?(calculator.current_location) %> +<% elsif uk_visa_application_centre_countries.include?(current_location) %> Your passport will be delivered to the UK Visa Application Centre where you applied - you must collect it in person. - <% if calculator.renewing_new? %> + <% if %w(renewing_new).include?(application_action) %> <%= render partial: 'getting_your_passport/contact.govspeak.erb' %> <%= render partial: 'getting_your_passport/id_renew_new.govspeak.erb' %> <% else %> <%= render partial: 'getting_your_passport/contact_and_id.govspeak.erb' %> <% end %> -<% elsif uk_visa_application_centre_variant_countries.include?(calculator.current_location) %> - <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { calculator: calculator } %> +<% elsif uk_visa_application_centre_variant_countries.include?(current_location) %> + <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { current_location: current_location } %> They will contact you with details of where to collect your passport when it arrives, using the contact details you provided on your form. - <% if calculator.renewing_new? %> - <% if collect_with_photo_id_countries.include?(calculator.current_location) %> + <% if %w(renewing_new).include?(application_action) %> + <% if collect_with_photo_id_countries.include?(current_location) %> You must bring photo ID with you. <% else %> @@ -32,34 +32,34 @@ <% else %> <%= render partial: 'getting_your_passport/id_apply_renew_old_replace.govspeak.erb' %> <% end %> -<% elsif named_embassy_countries.include?(calculator.current_location) %> - <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { calculator: calculator } %> -<% elsif collect_in_person_countries.include?(calculator.current_location) %> - <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { calculator: calculator } %> +<% elsif named_embassy_countries.include?(current_location) %> + <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { current_location: current_location } %> +<% elsif collect_in_person_countries.include?(current_location) %> + <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { current_location: current_location } %> <%= render partial: 'getting_your_passport/contact_and_id.govspeak.erb' %> -<% elsif collect_in_person_variant_countries.include?(calculator.current_location) %> - <% if %w(burundi).include?(calculator.current_location) %> - <% if calculator.renewing_new? %> +<% elsif collect_in_person_variant_countries.include?(current_location) %> + <% if %w(burundi).include?(current_location) %> + <% if %w(renewing_new).include?(application_action) %> Your passport will be delivered to the British Embassy Liaison Office in Bujumbura, Burundi - you must collect it in person. They will contact you - using the details on your application form - when your passport is ready to collect. You must bring your existing passport as photo ID. <% else %> - <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { current_location: current_location } %> <%= render partial: 'getting_your_passport/contact_and_id.govspeak.erb' %> <% end %> <% else %> - <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { current_location: current_location } %> <% end %> -<% elsif collect_in_person_renewing_new_variant_countries.include?(calculator.current_location) %> - <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { calculator: calculator } %> +<% elsif collect_in_person_renewing_new_variant_countries.include?(current_location) %> + <%= render partial: 'getting_your_passport/by_current_location.govspeak.erb', locals: { current_location: current_location } %> <%= render partial: 'getting_your_passport/contact.govspeak.erb' %> - <% if calculator.renewing_new? %> + <% if %w(renewing_new).include?(application_action) %> <%= render partial: 'getting_your_passport/id_renew_new.govspeak.erb' %> <% else %> <%= render partial: 'getting_your_passport/id_apply_renew_old_replace.govspeak.erb' %> <% end %> <% else %> - <%= render partial: 'getting_your_passport/by_ips_number.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'getting_your_passport/by_ips_number.govspeak.erb', locals: { ips_number: ips_number } %> <% end %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/_how_long.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/_how_long.govspeak.erb index 3f5375c203e..4af6b01704e 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/_how_long.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/_how_long.govspeak.erb @@ -1 +1 @@ -Your application <%= timing_prefix(calculator.optimistic_processing_time) %> <%= calculator.waiting_time %> from when it’s received by Her Majesty’s Passport Office in the UK. +Your application <%= timing_prefix(optimistic_processing_time) %> <%= waiting_time %> from when it’s received by Her Majesty’s Passport Office in the UK. diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/_how_to_apply.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/_how_to_apply.govspeak.erb index a58c1f8c524..24bea945269 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/_how_to_apply.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/_how_to_apply.govspeak.erb @@ -1,25 +1,25 @@ ## How to apply -<% unless calculator.ips_online_application? %> +<% if passport_data['online_application'].blank? %> 1. Download the application form. 2. Use the ‘Applying for a passport if you’re outside the UK’ guidance notes to help you fill in the application form. 3. Include 2 identical new photos of you (or your child, if it’s a child passport application). [Follow the rules about passport photos](/photos-for-passports) or your application may be delayed. 4. Check the guidance notes to find out which supporting documents you must send with your application. You must get documents that aren’t in English - including documents showing an address - fully translated by a professional translator. - <% if %w(afghanistan bangladesh india pakistan).include?(calculator.current_location) && calculator.child_or_adult == 'child' && calculator.applying? %> + <% if %w(afghanistan bangladesh india pakistan).include?(current_location) && child_or_adult == 'child' && application_action == 'applying' %> 5. Fill in the [parent contact details form](/government/publications/parents-contact-details-for-a-childs-first-british-passport) if either of the child's parents live in a different country to the child. <% end %> - <% if %w(pakistan).include?(calculator.current_location) %> + <% if %w(pakistan).include?(current_location) %> 5. You should fill in the [Applying for a passport from Pakistan form](https://www.gov.uk/government/publications/applying-for-a-passport-from-pakistan) if you are submitting supporting documents from the UK. <% end %> - <% case calculator.application_form %> + <% case application_form %> <% when 'hmpo_1_application_form' %> ^[Application form - applying for a British passport overseas](/government/publications/applying-for-a-passport-from-outside-the-uk-application-form)^ <% when 'hmpo_2_application_form' %> ^[Application form - applying for a British passport overseas](/government/publications/overseas-passport-application-form)^ <% end %> - <% case calculator.supporting_documents %> + <% case supporting_documents %> <% when 'ips_documents_group_1' %> ^[Guidance notes - applying for a passport if you’re outside the UK](/government/publications/overseas-passports-guidance)^ ^[Supporting documents you must send with your application](/government/publications/overseas-passport-applications-supporting-documents-guidance)^ @@ -31,7 +31,7 @@ ^[Supporting documents you must send with your application](/government/publications/overseas-passport-supporting-documents-group-3)^ <% end %> - <% case calculator.birth_location %> + <% case birth_location %> <% when 'south-africa' %> ^You must include your Vault birth certificate with your application – a photocopy won’t be accepted.^ <% when 'spain' %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/_making_your_application.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/_making_your_application.govspeak.erb index aebcee3b2c2..38dc81fdf9d 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/_making_your_application.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/_making_your_application.govspeak.erb @@ -1,7 +1,45 @@ -<% if calculator.uk_visa_application_centre? %> - <% if calculator.renewing_new? %> - <% if calculator.application_office? %> - <% if %w(laos vietnam).include?(calculator.current_location) %> +<% book_appointment_online_countries = %w(kyrgyzstan tajikistan turkmenistan uzbekistan) %> +<% uk_visa_application_centre_countries = %w(afghanistan algeria azerbaijan bangladesh belarus burundi burma cambodia china gaza georgia india indonesia kazakhstan kyrgyzstan laos lebanon mauritania morocco nepal pakistan russia tajikistan thailand turkmenistan ukraine uzbekistan western-sahara vietnam venezuela) %> +<% uk_visa_application_with_colour_pictures = %w(afghanistan azerbaijan algeria bangladesh belarus burma cambodia china georgia india indonesia kazakhstan laos lebanon mauritania morocco nepal pakistan tajikistan thailand turkmenistan ukraine uzbekistan russia vietnam venezuela western-sahara) %> +<% non_uk_visa_application_with_colour_pictures = %w(burma cuba sudan tajikistan turkmenistan uzbekistan) %> + +<% if application_address %> + <% case application_address %> + <% when 'durham' %> + ## Send your application + + Her Majesty’s Passport Office recommends you send your application using a secure delivery service or courier. + + + $A + Her Majesty’s Passport Office + OVS-D + Millburngate House + Millburngate + Durham + DH97 1PA + $A + <% when 'belfast' %> + ## Send your application + + Her Majesty’s Passport Office recommends you send your application using a secure delivery service or courier. + + + $A + Her Majesty’s Passport Office + OVS-B + Ground Floor + Law Society House + 90-106 Victoria Street + Belfast + BT1 3GN + United Kingdom + $A + <% end %> +<% elsif uk_visa_application_centre_countries.include?(current_location) %> + <% if %w(renewing_new).include?(application_action) %> + <% if passport_data['application_office'] %> + <% if %w(laos vietnam).include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> @@ -9,13 +47,13 @@ <%= render partial: 'making_your_application/bring_passport_and_full_photocopy.govspeak.erb' %> <%= render partial: 'making_your_application/book_appointment_by_email.govspeak.erb' %> - <% elsif calculator.uk_visa_application_with_colour_pictures? %> + <% elsif uk_visa_application_with_colour_pictures.include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_passport_and_full_photocopy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% else %> @@ -24,23 +62,23 @@ <%= render partial: 'making_your_application/apply_in_person.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_copy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_passport_and_full_photocopy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% end %> - <% unless calculator.book_appointment_online? %> - <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { calculator: calculator } %> + <% unless book_appointment_online_countries.include?(current_location) %> + <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { current_location: current_location } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% else %> - <% if %w(burundi gaza kyrgyzstan).include?(calculator.current_location) %> + <% if %w(burundi gaza kyrgyzstan).include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_passport_and_full_photocopy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% else %> @@ -50,26 +88,26 @@ <%= render partial: 'making_your_application/bring_originals_and_copy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_passport_and_full_photocopy.govspeak.erb' %> <% end %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'shared/overseas_passports_embassies.govspeak.erb', locals: { overseas_passports_embassies: overseas_passports_embassies } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% end %> <% else %> - <% if calculator.application_office? %> - <% if %w(laos vietnam).include?(calculator.current_location) %> + <% if passport_data['application_office'] %> + <% if %w(laos vietnam).include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> <%= render partial: 'making_your_application/book_appointment_by_email.govspeak.erb' %> - <% elsif calculator.uk_visa_application_with_colour_pictures? %> + <% elsif uk_visa_application_with_colour_pictures.include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% else %> @@ -77,22 +115,22 @@ <%= render partial: 'making_your_application/apply_in_person.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_copy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% end %> - <% unless calculator.book_appointment_online? %> - <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { calculator: calculator } %> + <% unless book_appointment_online_countries.include?(current_location) %> + <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { current_location: current_location } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% else %> - <% if %w(burundi gaza kyrgyzstan).include?(calculator.current_location) %> + <% if %w(burundi gaza kyrgyzstan).include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% else %> @@ -101,14 +139,14 @@ <%= render partial: 'making_your_application/apply_in_person.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_copy.govspeak.erb' %> <% end %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'shared/overseas_passports_embassies.govspeak.erb', locals: { overseas_passports_embassies: overseas_passports_embassies } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% end %> <% end %> -<% elsif %w(timor-leste).include?(calculator.current_location) %> +<% elsif %w(timor-leste).include?(current_location) %> ## Making your application You must submit your passport application through the New Zealand Embassy in Dili. @@ -118,68 +156,68 @@ You need to book an appointment - contact the embassy to arrange one. - <% unless calculator.book_appointment_online? %> - <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { calculator: calculator } %> + <% unless book_appointment_online_countries.include?(current_location) %> + <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { current_location: current_location } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> -<% elsif calculator.general_action == 'renewing' and calculator.renewing_country? %> - <% if calculator.application_office? %> - <% unless calculator.book_appointment_online? %> - <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { calculator: calculator } %> +<% elsif general_action == 'renewing' and data_query.renewing_countries?(current_location) %> + <% if passport_data['application_office'] %> + <% unless book_appointment_online_countries.include?(current_location) %> + <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { current_location: current_location } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% else %> - <% if calculator.non_uk_visa_application_with_colour_pictures? %> + <% if non_uk_visa_application_with_colour_pictures.include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_passport_and_full_photocopy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% else %> - <%= render partial: 'making_your_application/send_application_ips.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/send_application_ips.govspeak.erb', locals: { ips_number: ips_number } %> <%= render partial: 'making_your_application/renewing_new_renewing_old.govspeak.erb' %> <% end %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'shared/overseas_passports_embassies.govspeak.erb', locals: { overseas_passports_embassies: overseas_passports_embassies } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% end %> <% else %> - <% if calculator.application_office? %> - <% unless calculator.book_appointment_online? %> - <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { calculator: calculator } %> + <% if passport_data['application_office'] %> + <% unless book_appointment_online_countries.include?(current_location) %> + <%= render partial: 'making_your_application/send_application_address.govspeak.erb', locals: { current_location: current_location } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% else %> - <% if calculator.non_uk_visa_application_with_colour_pictures? %> + <% if non_uk_visa_application_with_colour_pictures.include?(current_location) %> ## Making your application <%= render partial: 'making_your_application/apply_in_person_or_via_proxy.govspeak.erb' %> <%= render partial: 'making_your_application/bring_originals_and_colour_copy.govspeak.erb' %> - <% unless calculator.book_appointment_online? %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'making_your_application/book_appointment_by_email_with_3_dates.govspeak.erb' %> <% end %> <% else %> - <%= render partial: 'making_your_application/send_application_ips.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/send_application_ips.govspeak.erb', locals: { ips_number: ips_number } %> <% end %> - <% if %w(st-helena-ascension-and-tristan-da-cunha).include?(calculator.current_location) %> - <% if calculator.renewing_new? %> + <% if %w(st-helena-ascension-and-tristan-da-cunha).include?(current_location) %> + <% if %w(renewing_new).include?(application_action) %> <%= render partial: 'making_your_application/renewing_new_renewing_old.govspeak.erb' %> <% end %> <%= render partial: 'making_your_application/send_application_address_st_helena_ascension_and_tristan_da_cunha.govspeak.erb' %> <% else %> - <% if calculator.ips_number.to_i > 1 %> - <% unless calculator.book_appointment_online? %> + <% if ips_number.to_i > 1 %> + <% unless book_appointment_online_countries.include?(current_location) %> <%= render partial: 'shared/overseas_passports_embassies.govspeak.erb', locals: { overseas_passports_embassies: overseas_passports_embassies } %> <% else %> - <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'making_your_application/book_appointment_online.govspeak.erb', locals: { current_location: current_location } %> <% end %> <% end %> <% end %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/_sending_your_application.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/_sending_your_application.govspeak.erb deleted file mode 100644 index eb57cbd0346..00000000000 --- a/lib/smart_answer_flows/overseas-passports/outcomes/_sending_your_application.govspeak.erb +++ /dev/null @@ -1,32 +0,0 @@ -<% case calculator.application_address %> -<% when 'durham' %> - ## Send your application - - Her Majesty’s Passport Office recommends you send your application using a secure delivery service or courier. - - - $A - Her Majesty’s Passport Office - OVS-D - Millburngate House - Millburngate - Durham - DH97 1PA - $A -<% when 'belfast' %> - ## Send your application - - Her Majesty’s Passport Office recommends you send your application using a secure delivery service or courier. - - - $A - Her Majesty’s Passport Office - OVS-B - Ground Floor - Law Society House - 90-106 Victoria Street - Belfast - BT1 3GN - United Kingdom - $A -<% end %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/apply_in_neighbouring_country.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/apply_in_neighbouring_country.govspeak.erb index cc5c9d516a7..c3d0fa0c71d 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/apply_in_neighbouring_country.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/apply_in_neighbouring_country.govspeak.erb @@ -1,11 +1,11 @@ <% content_for :title do %> - You can’t apply for a British passport from <%= calculator.world_location_name %>. + You can’t apply for a British passport from <%= title_output %>. <% end %> <% content_for :body do %> You should apply in a neighbouring country of your choice. - <% case calculator.current_location %> + <% case current_location %> <% when 'kyrgyzstan' %> If you need help with emergency travel arrangements, contact the [British Embassy in Almaty, Kazakhstan](/government/world/organisations/british-embassy-astana/office/british-embassy-office-almaty). <% when 'north-korea' %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/cannot_apply.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/cannot_apply.govspeak.erb index e4192d7eade..fbf173c14e4 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/cannot_apply.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/cannot_apply.govspeak.erb @@ -1,5 +1,5 @@ <% content_for :body do %> - <% case calculator.current_location %> + <% case current_location %> <% when 'iran' %> You can’t apply for a British passport from Iran at this time. diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/cost/_child_or_adult_passport.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/cost/_child_or_adult_passport.govspeak.erb index 44d40f6cfd1..e4558efa292 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/cost/_child_or_adult_passport.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/cost/_child_or_adult_passport.govspeak.erb @@ -1,6 +1,6 @@ -<% case calculator.ips_number %> +<% case ips_number %> <% when '1' %> - <% case calculator.child_or_adult %> + <% case child_or_adult %> <% when 'adult' %> | Passport type | Passport fee | Total to pay (including courier fee) | |---------------|--------------|--------------------------------------| @@ -12,7 +12,7 @@ | Child passport | £53.00 | £72.86 | <% end %> <% when '2' %> - <% case calculator.child_or_adult %> + <% case child_or_adult %> <% when 'adult' %> | Passport type | Passport fee | Total to pay (including courier fee) | |---------------|--------------|--------------------------------------| @@ -24,7 +24,7 @@ | Child passport | £53.00 | £77.72 | <% end %> <% when '3' %> - <% case calculator.child_or_adult %> + <% case child_or_adult %> <% when 'adult' %> | Passport type | Passport fee | Total to pay (including courier fee) | |---------------|--------------|--------------------------------------| diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/cost/_payment_instructions.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/cost/_payment_instructions.govspeak.erb index d34d62309e2..c09d0cc4087 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/cost/_payment_instructions.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/cost/_payment_instructions.govspeak.erb @@ -1,5 +1,5 @@ -<% case calculator.ips_number %> +<% case ips_number %> <% when '1' %> Fill in a [‘Paying by credit card or debit card’ form](/government/publications/overseas-passport-creditdebit-card-payment-authorisation) for each passport you’re applying for and submit it with your application. Your credit or debit card will be charged in sterling. diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_current_location.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_current_location.govspeak.erb index a8846c62349..b3b8e3c186b 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_current_location.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_current_location.govspeak.erb @@ -1,5 +1,5 @@ -<% case calculator.current_location %> +<% case current_location %> <% when 'angola' %> Your passport and supporting documents will be delivered to the British Embassy in Luanda, Angola - you must collect them in person. <% when 'benin' %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_ips_number.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_ips_number.govspeak.erb index cf7c4f1eda0..f1292d90164 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_ips_number.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_ips_number.govspeak.erb @@ -1,4 +1,4 @@ -<% case calculator.ips_number %> +<% case ips_number %> <% when '1' %> Your passport and supporting documents will be delivered separately by courier. <% when '2', '3' %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result.govspeak.erb index f2f301bac90..d6afe5ff865 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result.govspeak.erb @@ -1,8 +1,8 @@ <% content_for :body do %> ## How long it takes - <%= render partial: 'how_long.govspeak.erb', locals: { calculator: calculator } %> - <% if calculator.replacing? %> + <%= render partial: 'how_long.govspeak.erb', locals: { optimistic_processing_time: optimistic_processing_time, waiting_time: waiting_time } %> + <% if application_action == "replacing" %> If you haven’t already reported the loss or theft, you must include [form LS01](/government/publications/lost-or-stolen-passport-notification--2) with your passport application. <% end %> @@ -17,34 +17,45 @@ <%= render partial: 'cost.govspeak.erb', locals: { - calculator: calculator + data_query: data_query, + child_or_adult: child_or_adult, + ips_number: ips_number, + ips_docs_number: ips_docs_number, + current_location: current_location, + application_action: application_action } -%> <%= render partial: 'how_to_apply.govspeak.erb', locals: { - calculator: calculator + current_location: current_location, + passport_data: passport_data, + application_form: application_form, + supporting_documents: supporting_documents, + birth_location: birth_location, + child_or_adult: child_or_adult, + application_action: application_action } -%> - <% if calculator.application_address %> - <%= render partial: 'sending_your_application.govspeak.erb', - locals: { - calculator: calculator - } - -%> - <% else %> - <%= render partial: 'making_your_application.govspeak.erb', - locals: { - calculator: calculator, - overseas_passports_embassies: overseas_passports_embassies - } - -%> - <% end %> + <%= render partial: 'making_your_application.govspeak.erb', + locals: { + application_address: application_address, + application_action: application_action, + current_location: current_location, + passport_data: passport_data, + general_action: general_action, + ips_number: ips_number, + data_query: data_query, + overseas_passports_embassies: overseas_passports_embassies + } + -%> <%= render partial: 'getting_your_passport.govspeak.erb', locals: { - calculator: calculator + application_action: application_action, + current_location: current_location, + ips_number: ips_number } -%> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result_online.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result_online.govspeak.erb index 17e58768d4e..01b9f8bffea 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result_online.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result_online.govspeak.erb @@ -1,8 +1,8 @@ <% content_for :body do %> ## How long it takes - <%= render partial: 'how_long.govspeak.erb', locals: { calculator: calculator } %> - <% if calculator.replacing? %> + <%= render partial: 'how_long.govspeak.erb', locals: { optimistic_processing_time: optimistic_processing_time, waiting_time: waiting_time } %> + <% if application_action == "replacing" %> If you haven’t already reported the loss or theft, you must include [form LS01](/government/publications/lost-or-stolen-passport-notification--2) with your declaration form. <% end %> @@ -17,10 +17,10 @@ ## Cost - <% if calculator.replacing? and calculator.ips_number == '1' and calculator.ips_docs_number == '1' %> + <% if application_action == 'replacing' and ips_number == '1' and ips_docs_number == '1' %> You’ll have to pay a fee for your passport and a courier fee of £9.70. The courier fee pays for your passport to be sent back to you securely. - <% case calculator.child_or_adult %> + <% case child_or_adult %> <% when 'adult' %> | Passport type | Passport fee | Total to pay (including courier fee) | |---------------|--------------|--------------------------------------| @@ -32,7 +32,7 @@ | Child passport | £53.00 | £62.70 | <% end %> <% else %> - <% case calculator.ips_number %> + <% case ips_number %> <% when '1' %> You’ll have to pay a fee for your passport and a courier fee of £19.86. The courier fee pays for your passport and supporting documents to be sent back to you securely. <% when '2' %> @@ -41,18 +41,18 @@ You’ll have to pay a fee for your passport and a courier fee of £23.01. The courier fee pays for your passport to be sent securely to the British Embassy, high commission or consulate where you applied for you to collect. <% end %> - <%= render partial: 'cost/child_or_adult_passport.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'cost/child_or_adult_passport.govspeak.erb', locals: { ips_number: ips_number, child_or_adult: child_or_adult } %> <% end %> ## How to apply - <% if %w(hong-kong).include?(calculator.current_location) && %w(renewing replacing).include?(calculator.general_action) %> + <% if %w(hong-kong).include?(current_location) && %w(renewing replacing).include?(general_action) %> ^Read the information in [Cantonese](/government/publications/how-to-apply-for-a-british-national-overseas-passport-from-hong-kong).^ <% end %> You must apply and pay for your passport online. - <% case calculator.general_action %> + <% case general_action %> <% when 'applying' %> Before you start you need: @@ -75,7 +75,7 @@ - a MasterCard, Visa, Visa Electron, Visa Debit or Maestro (UK Domestic) card - Maestro (International) cards aren’t accepted <% end %> - <% case calculator.ips_docs_number %> + <% case ips_docs_number %> <% when '1' %> Read the [guidance notes](/government/publications/help-completing-the-online-passport-application-from-outside-the-uk) to help you fill in your online application. Check which [supporting documents](/government/publications/overseas-passport-applications-supporting-documents-guidance) you must send with your application. Any documents that aren’t in English (including documents showing an address) must be translated by a professional translator. <% when '2' %> @@ -83,13 +83,13 @@ <% when '3' %> Read the [guidance notes](/government/publications/help-completing-the-online-passport-application-from-outside-the-uk) to help you fill in your online application. Check which [supporting documents](/government/publications/overseas-passport-supporting-documents-group-3) you must send with your application. Any documents that aren’t in English (including documents showing an address) must be translated by a professional translator. <% end %> - <% case calculator.birth_location %> + <% case birth_location %> <% when 'south-africa' %> ^You must include your Vault birth certificate with your application – a photocopy won’t be accepted.^ <% when 'spain' %> ^You must include your full birth certificate (‘certificación literal’) with your application - a photocopy won’t be accepted.^ <% end %> - <% if %w(hong-kong).include?(calculator.current_location) %> + <% if %w(hong-kong).include?(current_location) %> ^You must provide a colour photocopy of your Hong Kong Permanent Identity Card with your application if you’re applying for a British National (Overseas) passport.^ <% end %> @@ -101,7 +101,7 @@ ## Getting your passport - <%= render partial: 'getting_your_passport/by_ips_number.govspeak.erb', locals: { calculator: calculator } %> + <%= render partial: 'getting_your_passport/by_ips_number.govspeak.erb', locals: { ips_number: ips_number } %> <%= render partial: 'passport_adviceline_contacts.govspeak.erb' %> <% end %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_online.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_online.govspeak.erb index 8fd4b2578fe..faa8514e4cf 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_online.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_online.govspeak.erb @@ -1,4 +1,4 @@ -<% case calculator.current_location %> +<% case current_location %> <% when 'kyrgyzstan' %> You must [book an appointment online](https://www.consular-appointments.service.gov.uk/fco/#!/british-embassy-bishkek/renew-or-apply-for-british-passport/slot_picker) to apply in person. <% when 'tajikistan' %> diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address.govspeak.erb index 472ae3a4a1c..ea00a04b5bc 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address.govspeak.erb @@ -1,5 +1,5 @@ -<% case calculator.current_location %> +<% case current_location %> <% when 'afghanistan' %> $A UK Visa Application Centre diff --git a/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_ips.govspeak.erb b/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_ips.govspeak.erb index 2814d50af3f..6044bad9235 100644 --- a/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_ips.govspeak.erb +++ b/lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_ips.govspeak.erb @@ -1,5 +1,5 @@ -<% case calculator.ips_number %> +<% case ips_number %> <% when '1' %> ## Send your application diff --git a/test/data/overseas-passports-files.yml b/test/data/overseas-passports-files.yml index 3ec60bc209a..8a2b0721db9 100644 --- a/test/data/overseas-passports-files.yml +++ b/test/data/overseas-passports-files.yml @@ -1,39 +1,38 @@ --- -lib/smart_answer_flows/overseas-passports.rb: a35c23b5e0a4ab31f95d6d45fa7e0d7c +lib/smart_answer_flows/overseas-passports.rb: ca4a6d321ee16b4b8a0f55f72dda7425 test/data/overseas-passports-questions-and-responses.yml: 4c6749fcf0a37deb135fc8c94fa52bc7 test/data/overseas-passports-responses-and-expected-results.yml: aca0c7e72dfbf84606a47cb7d6d7f758 -lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb: 548eee239b4195e500d106f6b72f26ce -lib/smart_answer_flows/overseas-passports/outcomes/_getting_your_passport.govspeak.erb: 51380cf8e939ed29c6009a89b729fb43 -lib/smart_answer_flows/overseas-passports/outcomes/_how_long.govspeak.erb: 4534bc621bd3d7af0ef7edf2fa50d6a1 -lib/smart_answer_flows/overseas-passports/outcomes/_how_to_apply.govspeak.erb: 7c2c5e04da62da72c90b54460df7f618 -lib/smart_answer_flows/overseas-passports/outcomes/_making_your_application.govspeak.erb: fa7e4bda21e87b9a1dc1f95af2270021 +lib/smart_answer_flows/overseas-passports/outcomes/_cost.govspeak.erb: 748ca30b4392d385f1546569cfc949fe +lib/smart_answer_flows/overseas-passports/outcomes/_getting_your_passport.govspeak.erb: 64f5a79f0445cc546af042f7b52d41b0 +lib/smart_answer_flows/overseas-passports/outcomes/_how_long.govspeak.erb: 2c3894ba2e5d37db57fd27ff20407f1a +lib/smart_answer_flows/overseas-passports/outcomes/_how_to_apply.govspeak.erb: aa0dbabc3e94b809e94c5d12cde5a590 +lib/smart_answer_flows/overseas-passports/outcomes/_making_your_application.govspeak.erb: 0fb3c49363768d09555070ebce60ecf3 lib/smart_answer_flows/overseas-passports/outcomes/_passport_adviceline_contacts.govspeak.erb: 2e10343ed7a17de7b3a5cd4b64af88b3 -lib/smart_answer_flows/overseas-passports/outcomes/_sending_your_application.govspeak.erb: c714b8c93aabaec437c746e0808b4774 -lib/smart_answer_flows/overseas-passports/outcomes/apply_in_neighbouring_country.govspeak.erb: 450d5b9388db82a2997d8f3c377e54ba -lib/smart_answer_flows/overseas-passports/outcomes/cannot_apply.govspeak.erb: 324c156c5c7985f2e9cc8592cf3f01e5 -lib/smart_answer_flows/overseas-passports/outcomes/cost/_child_or_adult_passport.govspeak.erb: 2e67f229f77cc61e21dcd10e1179ad90 -lib/smart_answer_flows/overseas-passports/outcomes/cost/_payment_instructions.govspeak.erb: 24592d5d1203d8875f6348369bdff530 -lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_current_location.govspeak.erb: e68f9748ebe6aac436b5b691114b4837 -lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_ips_number.govspeak.erb: b48467e6808000134440b110b77c5727 +lib/smart_answer_flows/overseas-passports/outcomes/apply_in_neighbouring_country.govspeak.erb: 15cd9b890f53c2158637042249abcf1c +lib/smart_answer_flows/overseas-passports/outcomes/cannot_apply.govspeak.erb: 7dd7460c2cb988931e7d354ddd122e4d +lib/smart_answer_flows/overseas-passports/outcomes/cost/_child_or_adult_passport.govspeak.erb: 77472a0695b1f28fcbddfcf0e7dbeb46 +lib/smart_answer_flows/overseas-passports/outcomes/cost/_payment_instructions.govspeak.erb: 61d7e9bd489ab9f5e5180f758e32a9f2 +lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_current_location.govspeak.erb: c7a4c2c5c3d2d07620c7cdf354e9eed7 +lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_by_ips_number.govspeak.erb: b49015f9708426cf4a4e42e4bfe31b65 lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_contact.govspeak.erb: 5ad64ad5edf8a5366f94b292afc8a777 lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_contact_and_id.govspeak.erb: b60ef00dd46212b7003f0b83623f0a1f lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_id_apply_renew_old_replace.govspeak.erb: a59de939591dba0a00deb469b0ff5f51 lib/smart_answer_flows/overseas-passports/outcomes/getting_your_passport/_id_renew_new.govspeak.erb: 5dedbcae3a018d10f2ce06d143baec67 -lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result.govspeak.erb: d2161d62c853013245db421db6f05884 -lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result_online.govspeak.erb: a0f9cbbb795766a470c62952718918ca +lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result.govspeak.erb: c04e6613f701435dfc309a2898c119b2 +lib/smart_answer_flows/overseas-passports/outcomes/ips_application_result_online.govspeak.erb: 903b79cb33764db43f7b361a17e1fffc lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_apply_in_person.govspeak.erb: 0c53679c9a5bade801983b029dc8c862 lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_apply_in_person_or_via_proxy.govspeak.erb: ecd3a646c341b2339978f31b7a16f7a1 lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_by_email.govspeak.erb: fce872e417a5ddf0e678ffd3a2fdceab lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_by_email_with_3_dates.govspeak.erb: d44f76a663c17e1fad2c18a171b0dd05 -lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_online.govspeak.erb: 413f7796b96641f7bd020eba2884c8c0 +lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_book_appointment_online.govspeak.erb: 0e87a8676fac5b438b4ee10af2e835a2 lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_bring_originals_and_colour_copy.govspeak.erb: b63f0033724c6de7ed1259464224025f lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_bring_originals_and_copy.govspeak.erb: ad73d5bfff65c53c904d57317b31ad78 lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_bring_passport_and_full_photocopy.govspeak.erb: ae1130cb57b05f62e626177e9e2b56bb lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_renewing_new_renewing_old.govspeak.erb: 4d28bc50f6376d50bc38d009c8c0e6e8 -lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address.govspeak.erb: fa558ad57205827e4c3e126ab89af5df +lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address.govspeak.erb: f43ed371137a9dfd6377dc1571e8cd6f ? lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_address_st_helena_ascension_and_tristan_da_cunha.govspeak.erb : 2d26915c82ab45dc80dfef305ed02d72 -lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_ips.govspeak.erb: 1de29659a95f40c98fd2406424691e52 +lib/smart_answer_flows/overseas-passports/outcomes/making_your_application/_send_application_ips.govspeak.erb: a7c04b6408132e0b3a2b6b20bc2d4da5 lib/smart_answer_flows/overseas-passports/overseas_passports.govspeak.erb: 7106e947778ef18645fe2b2443253ba1 lib/smart_answer_flows/overseas-passports/questions/child_or_adult_passport.govspeak.erb: de1ecc79e4cb16f10da8c57a75b6e16d lib/smart_answer_flows/overseas-passports/questions/country_of_birth.govspeak.erb: 85ba3f293ef7fb89e6ea5aa7d30623c3 @@ -44,7 +43,7 @@ lib/smart_answer_flows/overseas-passports/questions/which_country_are_you_in.gov lib/smart_answer_flows/overseas-passports/questions/which_opt.govspeak.erb: 0f629592f57a5ec972f23bf170d37714 lib/smart_answer_flows/shared/_overseas_passports_embassies.govspeak.erb: 2f521bae99c2f48b49d07bcb283a8063 lib/smart_answer/overseas_passports_helper.rb: 07df4cd921e62464c2dc9534b4d8cdf8 -lib/smart_answer/calculators/passport_and_embassy_data_query.rb: 21c2a74b8496d437ffd204d70ad5b366 +lib/smart_answer/calculators/passport_and_embassy_data_query.rb: b23c4733dacdb05308a843f3a89afac7 test/fixtures/worldwide_locations.yml: 063711faceec3a4081d6d5fb386c8029 test/fixtures/worldwide/france_organisations.json: dec146460928937fba71409755f01ba3 test/fixtures/worldwide/st-martin_organisations.json: 120d85d68f897fc762724a41a4c650a6 diff --git a/test/integration/smart_answer_flows/overseas_passports_test.rb b/test/integration/smart_answer_flows/overseas_passports_test.rb index 0b71b1fc7ca..d86ca78c5c9 100644 --- a/test/integration/smart_answer_flows/overseas_passports_test.rb +++ b/test/integration/smart_answer_flows/overseas_passports_test.rb @@ -27,6 +27,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if you are renewing, replacing or applying for a passport" do assert_current_node :renewing_replacing_applying? + assert_state_variable :current_location, 'afghanistan' end context "answer applying" do setup do @@ -39,6 +40,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase should "give the result and be done" do add_response 'adult' add_response 'afghanistan' + assert_state_variable :application_type, 'ips_application_3' assert_current_node :ips_application_result end end @@ -54,6 +56,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase context "answer adult" do should "give the result and be done" do add_response 'adult' + assert_state_variable :application_type, 'ips_application_3' assert_current_node :ips_application_result end end @@ -69,6 +72,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase context "answer adult" do should "give the result and be done" do add_response 'adult' + assert_state_variable :application_type, 'ips_application_3' assert_current_node :ips_application_result end end @@ -83,6 +87,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if you are renewing, replacing or applying for a passport" do assert_current_node :renewing_replacing_applying? + assert_state_variable :current_location, 'iraq' end context "answer applying" do setup do @@ -90,6 +95,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if the passport is for an adult or a child" do assert_current_node :child_or_adult_passport? + assert_state_variable :application_type, 'ips_application_1' end context "answer adult" do setup do @@ -132,12 +138,15 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if you are renewing, replacing or applying for a passport" do assert_current_node :renewing_replacing_applying? + assert_state_variable :current_location, 'austria' end context "answer applying" do setup do add_response 'applying' end should "ask if the passport is for an adult or a child" do + assert_state_variable :application_type, 'ips_application_1' + assert_state_variable :ips_number, "1" assert_current_node :child_or_adult_passport? end context "answer adult" do @@ -152,6 +161,10 @@ class OverseasPassportsTest < ActiveSupport::TestCase add_response 'greece' end + should "use the greek document group in the results" do + assert_state_variable :supporting_documents, 'ips_documents_group_2' + end + should "give the result" do assert_current_node :ips_application_result_online end @@ -178,7 +191,9 @@ class OverseasPassportsTest < ActiveSupport::TestCase context "answer adult" do should "give the result and be done" do add_response 'adult' + assert_state_variable :supporting_documents, 'ips_documents_group_1' assert_current_node :ips_application_result_online + assert_state_variable :embassy_address, nil end end end # Replacing @@ -240,6 +255,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if you are renewing, replacing or applying for a passport" do assert_current_node :renewing_replacing_applying? + assert_state_variable :current_location, 'albania' end context "answer applying" do setup do @@ -247,6 +263,8 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if the passport is for an adult or a child" do assert_current_node :child_or_adult_passport? + assert_state_variable :application_type, 'ips_application_1' + assert_state_variable :ips_number, "1" end context "answer adult" do setup do @@ -259,12 +277,16 @@ class OverseasPassportsTest < ActiveSupport::TestCase should "give the application result" do add_response "spain" assert_current_node :ips_application_result_online + assert_state_variable :embassy_address, nil + assert_state_variable :supporting_documents, 'ips_documents_group_1' end end context "answer UK" do - should "give the application result" do + should "give the application result with the UK documents" do add_response "united-kingdom" assert_current_node :ips_application_result_online + assert_state_variable :embassy_address, nil + assert_state_variable :supporting_documents, 'ips_documents_group_3' end end end @@ -279,11 +301,14 @@ class OverseasPassportsTest < ActiveSupport::TestCase end should "ask if you are renewing, replacing or applying for a passport" do assert_current_node :renewing_replacing_applying? + assert_state_variable :current_location, 'azerbaijan' end context "answer replacing adult passport" do setup do add_response 'replacing' add_response 'adult' + assert_state_variable :application_type, 'ips_application_3' + assert_state_variable :ips_number, "3" end should "give the IPS application result" do assert_current_node :ips_application_result @@ -457,6 +482,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase add_response 'renewing_new' add_response 'adult' assert_current_node :ips_application_result + assert_state_variable :send_colour_photocopy_bulletpoint, nil end end # nepal (IPS3 with custom phrases) @@ -467,6 +493,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase add_response 'replacing' add_response 'adult' assert_current_node :ips_application_result + assert_state_variable :send_colour_photocopy_bulletpoint, nil end end # nepal (IPS1 with custom phrases) @@ -513,6 +540,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase add_response 'adult' add_response 'united-kingdom' assert_current_node :ips_application_result + assert_state_variable :application_address, 'durham' assert_match /Millburngate House/, outcome_body end end # Kenya (custom phrases) @@ -525,6 +553,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase add_response 'adult' add_response 'united-kingdom' assert_current_node :ips_application_result + assert_state_variable :application_address, 'durham' assert_match /Millburngate House/, outcome_body end end # Kenya (custom phrases) @@ -750,6 +779,7 @@ class OverseasPassportsTest < ActiveSupport::TestCase worldwide_api_has_organisations_for_location('british-indian-ocean-territory', read_fixture_file('worldwide/british-indian-ocean-territory_organisations.json')) add_response 'british-indian-ocean-territory' assert_current_node :apply_in_neighbouring_country + assert_state_variable :title_output, 'British Indian Ocean Territory' end end # british-indian-ocean-territory diff --git a/test/unit/calculators/overseas_passports_calculator_test.rb b/test/unit/calculators/overseas_passports_calculator_test.rb deleted file mode 100644 index 6a9776609b9..00000000000 --- a/test/unit/calculators/overseas_passports_calculator_test.rb +++ /dev/null @@ -1,634 +0,0 @@ -require_relative "../../test_helper" - -module SmartAnswer - module Calculators - class OverseasPassportsCalculatorTest < ActiveSupport::TestCase - context '#current_location' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'allow current_location to be written and read' do - @calculator.current_location = 'springfield' - assert_equal @calculator.current_location, 'springfield' - end - end - - context '#book_appointment_online?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true if current_location is in BOOK_APPOINTMENT_ONLINE_COUNTRIES countries' do - OverseasPassportsCalculator::BOOK_APPOINTMENT_ONLINE_COUNTRIES.each do |country| - @calculator.current_location = country - assert @calculator.book_appointment_online? - end - end - - should 'be false if current_location is not in BOOK_APPOINTMENT_ONLINE_COUNTRIES' do - @calculator.current_location = 'antarctica' - refute @calculator.book_appointment_online? - end - end - - context '#uk_visa_application_centre?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true if current_location is in UK_VISA_APPLICATION_CENTRE_COUNTRIES countries' do - OverseasPassportsCalculator::UK_VISA_APPLICATION_CENTRE_COUNTRIES.each do |country| - @calculator.current_location = country - assert @calculator.uk_visa_application_centre? - end - end - - should 'be false if current_location is not in UK_VISA_APPLICATION_CENTRE_COUNTRIES' do - @calculator.current_location = 'antarctica' - refute @calculator.uk_visa_application_centre? - end - end - - - context '#uk_visa_application_with_colour_pictures?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true if current_location is in UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES' do - OverseasPassportsCalculator::UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES.each do |country| - @calculator.current_location = country - assert @calculator.uk_visa_application_with_colour_pictures? - end - end - - should 'be false if current_location is not in UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES' do - @calculator.current_location = 'antarctica' - refute @calculator.uk_visa_application_with_colour_pictures? - end - end - - - context '#non_uk_visa_application_with_colour_pictures?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true if current_location is in NON_UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES' do - OverseasPassportsCalculator::NON_UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES.each do |country| - @calculator.current_location = country - assert @calculator.non_uk_visa_application_with_colour_pictures? - end - end - - should 'be false if current_location is not in NON_UK_VISA_APPLICATION_WITH_COLOUR_PICTURES_COUNTRIES' do - @calculator.current_location = 'antarctica' - refute @calculator.non_uk_visa_application_with_colour_pictures? - end - end - - context '#ineligible_country?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true if current_location is in INELIGIBLE_COUNTRIES' do - OverseasPassportsCalculator::INELIGIBLE_COUNTRIES.each do |country| - @calculator.current_location = country - assert @calculator.ineligible_country? - end - end - - should 'be false if current_location is not in INELIGIBLE_COUNTRIES' do - @calculator.current_location = 'antarctica' - refute @calculator.ineligible_country? - end - end - - context '#apply_in_neighbouring_countries?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true if current_location is in APPLY_IN_NEIGHBOURING_COUNTRIES' do - OverseasPassportsCalculator::APPLY_IN_NEIGHBOURING_COUNTRIES.each do |country| - @calculator.current_location = country - assert @calculator.apply_in_neighbouring_countries? - end - end - - should 'be false if current_location is not in APPLY_IN_NEIGHBOURING_COUNTRIES' do - @calculator.current_location = 'antarctica' - refute @calculator.apply_in_neighbouring_countries? - end - end - - context '#alternate_embassy_location' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return a alt location if the location is in PassportAndEmbassyDataQuery::ALT_EMBASSIES' do - PassportAndEmbassyDataQuery::ALT_EMBASSIES.each do |location, alternate_location| - assert_equal @calculator.alternate_embassy_location(location), alternate_location - end - end - - should 'return nil if the location is not in PassportAndEmbassyDataQuery::ALT_EMBASSIES' do - assert_nil @calculator.alternate_embassy_location('antarctica') - end - end - - context '#world_location' do - setup do - @calculator = OverseasPassportsCalculator.new - @calculator.current_location = 'some location' - end - - context 'given alternate_embassy_location is nil' do - setup do - @calculator.stubs(:alternate_embassy_location).returns(nil) - end - - should 'return the world location for the location' do - WorldLocation.stubs(:find).with('location').returns('world_location') - - assert_equal 'world_location', @calculator.world_location('location') - end - - should 'return nil if a world location cannot be found for the location' do - WorldLocation.stubs(:find).with('location').returns(nil) - - assert_nil @calculator.world_location('location') - end - end - - context 'given alternate_embassy_location is present' do - setup do - @calculator.stubs(:alternate_embassy_location).returns('another location') - end - - should 'return the world location for alternate_embassy_location' do - WorldLocation.stubs(:find).with(@calculator.alternate_embassy_location).returns('world_location') - - assert_equal 'world_location', @calculator.world_location('another location') - end - - should 'return nil if a world location cannot be found for the alternate_embassy_location' do - WorldLocation.stubs(:find).with(@calculator.alternate_embassy_location).returns(nil) - - assert_nil @calculator.world_location('another location') - end - end - - context '#world_location_name' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return the name of the world location associated with the location' do - @calculator.stubs(:world_location).with('location').returns(stub(name: 'world-location-name')) - - assert_equal 'world-location-name', @calculator.world_location_name('location') - end - end - - context '#fco_organisation' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return the fco organisation for the world location with the location' do - @calculator.stubs(:world_location).with('location').returns(stub(fco_organisation: 'fco-organisation')) - - assert_equal 'fco-organisation', @calculator.fco_organisation('location') - end - - should "return nil if the world location doesn't have an fco organisation" do - @calculator.stubs(:world_location).with('location').returns(stub(fco_organisation: nil)) - - assert_nil @calculator.fco_organisation('location') - end - end - - context '#cash_only_country?' do - should 'delegate to the data_query' do - data_query = PassportAndEmbassyDataQuery.new - data_query.stubs(:cash_only_countries?).with('antarctica').returns(true) - - @calculator = OverseasPassportsCalculator.new(data_query: data_query) - @calculator.current_location = 'antarctica' - - assert @calculator.cash_only_country? - end - end - - context '#renewing_country?' do - should 'delegate to the data query' do - data_query = PassportAndEmbassyDataQuery.new - data_query.stubs(:renewing_countries?).with('antarctica').returns(true) - - @calculator = OverseasPassportsCalculator.new(data_query: data_query) - @calculator.current_location = 'antarctica' - - assert @calculator.renewing_country? - end - end - - context '#renewing_new?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when renewing a new passport' do - @calculator.application_action = 'renewing_new' - assert @calculator.renewing_new? - end - - should 'be false when not renewing a new passport' do - @calculator.application_action = 'renewing_old' - refute @calculator.renewing_new? - end - end - - context '#renewing_old?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when renewing an old passport' do - @calculator.application_action = 'renewing_old' - assert @calculator.renewing_old? - end - - should 'be false when not renewing an old passport' do - @calculator.application_action = 'renewing_new' - refute @calculator.renewing_old? - end - end - - context '#applying?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when applying for a new passport' do - @calculator.application_action = 'applying' - assert @calculator.applying? - end - - should 'be false when not applying for a new passport' do - @calculator.application_action = 'replacing' - refute @calculator.applying? - end - end - - context '#replacing?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when replacing a passport' do - @calculator.application_action = 'replacing' - assert @calculator.replacing? - end - - should 'be false when not replacing a new passport' do - @calculator.application_action = 'applying' - refute @calculator.replacing? - end - end - - context '#overseas_passports_embassies' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return the offices that offer an overseas passport service' do - world_office = stub('World Office') - organisation = stub.quacks_like(WorldwideOrganisation.new({})) - organisation.stubs(:offices_with_service).with('Overseas Passports Service').returns([world_office]) - @calculator.stubs(:fco_organisation).with('location').returns(organisation) - - assert_equal [world_office], @calculator.overseas_passports_embassies('location') - end - - should 'return an empty array when there is no FCO organisation' do - @calculator.stubs(:fco_organisation).with('location').returns(nil) - - assert_equal [], @calculator.overseas_passports_embassies('location') - end - end - - context '#general_action' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - context 'given application action is renewing_new' do - should 'equal renewing' do - @calculator.application_action = 'renewing_new' - assert_equal @calculator.general_action, 'renewing' - end - end - - context 'given application action is renewing_old' do - should 'equal renewing' do - @calculator.application_action = 'renewing_old' - assert_equal @calculator.general_action, 'renewing' - end - end - - context 'given application action is replacing' do - should 'equal replacing' do - @calculator.application_action = 'replacing' - assert_equal @calculator.general_action, 'replacing' - end - end - - context 'given application action is applying' do - should 'equal applying' do - @calculator.application_action = 'applying' - assert_equal @calculator.general_action, 'applying' - end - end - end - - context '#passport_data' do - should 'delegate to the data_query' do - data_query = PassportAndEmbassyDataQuery.new - data_query.stubs(:find_passport_data).with('antarctica').returns('passport-data') - - @calculator = OverseasPassportsCalculator.new(data_query: data_query) - @calculator.current_location = 'antarctica' - - assert_equal 'passport-data', @calculator.passport_data - end - - context 'when receiving an argument value' do - should 'delegate to the data_query with the argument value' do - data_query = PassportAndEmbassyDataQuery.new - data_query.stubs(:find_passport_data).with('arctic').returns('passport-data') - - @calculator = OverseasPassportsCalculator.new(data_query: data_query) - - assert_equal 'passport-data', @calculator.passport_data('arctic') - end - end - end - - context '#application_type' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'returns type from passport_data' do - application_type = 'application_type_x' - @calculator.stubs(:passport_data).returns('type' => 'application_type_x') - - assert_equal application_type, @calculator.application_type - end - - should 'return nil when passport_data is nil' do - @calculator.stubs(:passport_data).returns(nil) - - assert_nil @calculator.application_type - end - end - - context '#application_form' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'returns app_form from passport_data' do - application_form = 'application_form_1' - @calculator.stubs(:passport_data).returns('app_form' => 'application_form_1') - - assert_equal application_form, @calculator.application_form - end - - should 'return nil when passport_data is nil' do - @calculator.stubs(:passport_data).returns(nil) - - assert_nil @calculator.application_form - end - end - - context '#application_office?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when the passport_data application_office is present' do - @calculator.stubs(:passport_data).returns('application_office' => 'some office') - - assert @calculator.application_office? - end - - should 'be false when the passport_data application_office is blank' do - @calculator.stubs(:passport_data).returns('application_office' => nil) - - refute @calculator.application_office? - end - - should 'return nil when passport data is nil' do - @calculator.stubs(:passport_data).returns(nil) - - refute @calculator.application_office? - end - end - - context '#optimistic_processing_time' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return the optimistic_processing_time? from passport_data' do - @calculator.stubs(:passport_data).returns('optimistic_processing_time?' => 10) - - assert_equal 10, @calculator.optimistic_processing_time - end - - should 'return nil when passport data is nil' do - @calculator.stubs(:passport_data).returns(nil) - - assert_nil @calculator.optimistic_processing_time - end - end - - context '#waiting_time' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'returns the waiting time for an application action from passport_data' do - actions = { 'renewing_new' => 1, 'renewing_old' => 2, 'applying' => 3, 'replacing' => 4 } - @calculator.stubs(:passport_data).returns(actions) - - actions.each do |action, time| - @calculator.application_action = action - assert time, @calculator.waiting_time - end - end - - should 'return nil when passport_data is nil' do - @calculator.stubs(:passport_data).returns(nil) - - assert_nil @calculator.waiting_time - end - end - - context '#application_address' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'returns address from passport_data' do - application_address = 'application_address_1' - @calculator.stubs(:passport_data).returns('address' => 'application_address_1') - - assert_equal application_address, @calculator.application_address - end - - should 'return nil when passport_data is nil' do - @calculator.stubs(:passport_data).returns(nil) - - assert_nil @calculator.application_address - end - end - - context '#application_group' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'returns group from passport_data for the given location' do - application_group = 'application_group_data' - @calculator.stubs(:passport_data).with('test-location').returns('group' => 'application_group_data') - - assert_equal application_group, @calculator.application_group('test-location') - end - - should 'return nil when passport_data is nil' do - @calculator.stubs(:passport_data).with('test-location').returns(nil) - - assert_nil @calculator.application_group('test-location') - end - end - - context '#supporting_documents' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return application_group for the current_location when birth_location is blank' do - @calculator.birth_location = nil - @calculator.current_location = 'current location' - @calculator.stubs(:application_group).with('current location').returns('supporting docs') - - assert_equal 'supporting docs', @calculator.supporting_documents - end - - should 'return application_group for current_location when birth location is united-kingdom' do - @calculator.birth_location = 'united kingdom' - @calculator.current_location = 'current location' - @calculator.stubs(:application_group).with('united kingdom').returns('supporting docs') - - assert_equal 'supporting docs', @calculator.supporting_documents - end - - should 'return application_group for birth_location when birth_location is present and not united-kingdom' do - @calculator.birth_location = 'birth location' - @calculator.current_location = 'current location' - @calculator.stubs(:application_group).with('birth location').returns('supporting docs') - - assert_equal 'supporting docs', @calculator.supporting_documents - end - end - - context '#ips_application?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when application_type is in IPS_APPLICATION_TYPES' do - OverseasPassportsCalculator::IPS_APPLICATION_TYPES.each do |type| - @calculator.stubs(:application_type).returns(type) - assert @calculator.ips_application? - end - end - - should 'be false when application_type is not in IPS_APPLICATION_TYPES' do - @calculator.stubs(:application_type).returns('application_type_x') - - refute @calculator.ips_application? - end - end - - context '#ips_online_application?' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'be true when passport_data online_application is present' do - @calculator.stubs(:passport_data).returns('online_application' => 'apply online') - - assert @calculator.ips_online_application? - end - - should 'be false when passport_data is blank' do - @calculator.stubs(:passport_data).returns(nil) - - refute @calculator.ips_online_application? - end - - should 'be false when passport_data online_application is blank' do - @calculator.stubs(:passport_data).returns('online_application' => nil) - - refute @calculator.ips_online_application? - end - end - - context '#ips_number' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return the IPS number when application_type is an IPS application' do - OverseasPassportsCalculator::IPS_APPLICATION_TYPES.each do |type| - @calculator.stubs(:application_type).returns(type) - assert_equal type.last, @calculator.ips_number - end - end - - should 'return nil when application_type is not an IPS application' do - @calculator.stubs(:application_type).returns('application_type_x') - - assert_nil @calculator.ips_number - end - end - - context '#ips_docs_number' do - setup do - @calculator = OverseasPassportsCalculator.new - end - - should 'return the IPS docs number when application_type is an IPS application' do - @calculator.stubs(:supporting_documents).returns("ips_documents_group_1") - @calculator.stubs(:ips_application?).returns(true) - - assert_equal "ips_documents_group_1".last, @calculator.ips_docs_number - end - - should 'return nil when application_type is not an IPS application' do - @calculator.stubs(:ips_application?).returns(false) - - assert_nil @calculator.ips_docs_number - end - end - end - end - end -end diff --git a/test/unit/calculators/passport_and_embassy_data_query_test.rb b/test/unit/calculators/passport_and_embassy_data_query_test.rb index 2200d4cf37a..9eb6d5b8152 100644 --- a/test/unit/calculators/passport_and_embassy_data_query_test.rb +++ b/test/unit/calculators/passport_and_embassy_data_query_test.rb @@ -20,6 +20,17 @@ class PassportAndEmbassyDataQueryTest < ActiveSupport::TestCase assert_equal '14 weeks', @query.find_passport_data('afghanistan')['replacing'] end end + + context "passport_costs" do + should "format passport costs" do + %w(south_african_rand_adult_32 south_african_rand_adult_48 south_african_rand_child + euros_adult_32 euros_adult_48 euros_child).each do |k| + assert @query.passport_costs.has_key?(k), "passport_costs should have key #{k}" + end + assert_match /^\d,\d\d\d South African Rand/, @query.passport_costs["south_african_rand_adult_48"] + end + end + end end end