Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into birth_death_updates

  • Loading branch information...
commit cc580dea28d2f17d4cef5578ac96d5e98113bd4a 2 parents 2e55d56 + dcf53ba
@jackfranklin jackfranklin authored
View
3  lib/flows/register-a-birth.rb
@@ -1,4 +1,5 @@
-status :draft
+status :published
+satisfies_need "2759"
reg_data_query = SmartAnswer::Calculators::RegistrationsDataQuery.new
embassy_data_query = SmartAnswer::Calculators::PassportAndEmbassyDataQuery.new
View
183 lib/flows/register-a-death-v2.rb
@@ -1,183 +0,0 @@
-status :draft
-
-data_query = SmartAnswer::Calculators::RegistrationsDataQuery.new
-exclusions = %w(afghanistan cambodia central-african-republic chad comoros
- dominican-republic east-timor eritrea haiti kosovo laos lesotho
- liberia madagascar montenegro paraguay samoa slovenia somalia
- swaziland taiwan tajikistan western-sahara)
-no_embassies = %w(iran syria yemen)
-
-# Q1
-multiple_choice :where_did_the_death_happen? do
- save_input_as :where_death_happened
- option :england_wales => :did_the_person_die_at_home_hospital?
- option :scotland => :did_the_person_die_at_home_hospital?
- option :northern_ireland => :did_the_person_die_at_home_hospital?
- option :overseas => :which_country?
-end
-# Q2
-multiple_choice :did_the_person_die_at_home_hospital? do
- option :at_home_hospital
- option :elsewhere
- calculate :died_at_home_hospital do
- responses.last == 'at_home_hospital'
- end
- next_node :was_death_expected?
-end
-# Q3
-multiple_choice :was_death_expected? do
- option :yes
- option :no
-
- calculate :death_expected do
- responses.last == 'yes'
- end
- next_node do |response|
- if where_death_happened == 'overseas'
- :which_country?
- else
- :uk_result
- end
- end
-end
-# Q4
-country_select :which_country? do
- save_input_as :country
- calculate :country_name do
- SmartAnswer::Question::CountrySelect.countries.find { |c| c[:slug] == responses.last }[:name]
- end
- calculate :current_location do
- data_query.registration_country_slug(responses.last) || responses.last
- end
- calculate :current_location_name do
- SmartAnswer::Question::CountrySelect.countries.find { |c| c[:slug] == current_location }[:name]
- end
- next_node do |response|
- if data_query.commonwealth_country?(response)
- :commonwealth_result
- elsif no_embassies.include?(response)
- :no_embassy_result
- else
- :where_are_you_now?
- end
- end
-end
-# Q5
-multiple_choice :where_are_you_now? do
- option :same_country => :embassy_result
- option :another_country => :which_country_are_you_in_now?
- option :back_in_the_uk => :fco_result
-
- calculate :another_country do
- responses.last == 'another_country'
- end
-end
-# Q6
-country_select :which_country_are_you_in_now? do
- save_input_as :current_location
- calculate :current_location_name do
- country_slug = data_query.registration_country_slug(responses.last)
- SmartAnswer::Question::CountrySelect.countries.find { |c| c[:slug] == country_slug }[:name]
- end
- next_node :embassy_result
-end
-
-outcome :commonwealth_result
-outcome :no_embassy_result
-
-outcome :uk_result do
- precalculate :content_sections do
- sections = PhraseList.new
- if where_death_happened == 'england_wales'
- sections << :intro_ew << :who_can_register
- sections << (died_at_home_hospital ? :who_can_register_home_hospital : :who_can_register_elsewhere)
- sections << :"what_you_need_to_do_#{death_expected ? :expected : :unexpected}"
- sections << :need_to_tell_registrar
- sections << :"documents_youll_get_ew_#{death_expected ? :expected : :unexpected}"
- else
- sections << :"intro_#{where_death_happened}"
- end
- sections
- end
-end
-
-outcome :fco_result do
- precalculate :embassy_high_commission_or_consulate do
- data_query.has_high_commission?(current_location) ? "High commission" :
- data_query.has_consulate?(current_location) ? "British embassy or consulate" :
- "British embassy"
- end
- precalculate :registration_footnote do
- exclusions.include?(country) ? '' : PhraseList.new(:reg_footnote)
- end
-end
-
-outcome :embassy_result do
- precalculate :embassy_high_commission_or_consulate do
- data_query.has_high_commission?(current_location) ? "High commission" :
- data_query.has_consulate?(current_location) ? "British embassy or consulate" :
- "British embassy"
- end
-
- precalculate :clickbook do
- result = ''
- clickbook = data_query.clickbook(current_location)
- i18n_prefix = "flow.register-a-death-v2"
- unless clickbook.nil?
- if clickbook.class == Hash
- result = I18n.translate!("#{i18n_prefix}.phrases.multiple_clickbooks_intro") << "\n"
- clickbook.each do |k,v|
- result += %Q(- #{I18n.translate!(i18n_prefix + ".phrases.clickbook_link",
- title: k, clickbook_url: v)})
- end
- else
- result = I18n.translate!("#{i18n_prefix}.phrases.clickbook_link",
- title: "Book an appointment online", clickbook_url: clickbook)
- end
- end
-
- result
- end
-
- precalculate :postal_form_url do
- data_query.death_postal_form(current_location)
- end
-
- precalculate :postal_return_form_url do
- data_query.death_postal_return_form(current_location)
- end
-
- precalculate :postal do
- if data_query.register_death_by_post?(current_location)
- phrases = PhraseList.new(:postal_intro)
- if postal_form_url
- phrases << :postal_registration_by_form
- else
- phrases << :"postal_registration_#{current_location}"
- end
- phrases << :postal_delivery_form if postal_return_form_url
- phrases
- else
- ''
- end
- end
-
- precalculate :cash_only do
- data_query.cash_only?(current_location) ? PhraseList.new(:cash_only) : ''
- end
-
- precalculate :embassy_address do
- data = SmartAnswer::Calculators::PassportAndEmbassyDataQuery.new.find_embassy_data(current_location)
- data.first['address'] if data
- end
-
- precalculate :footnote do
- if exclusions.include?(country)
- PhraseList.new(:footnote_exceptions)
- elsif another_country
- PhraseList.new(:footnote_another_country)
- else
- PhraseList.new(:footnote)
- end
- end
-end
View
166 lib/flows/register-a-death.rb
@@ -1,35 +1,93 @@
satisfies_need "2189"
status :published
+data_query = SmartAnswer::Calculators::RegistrationsDataQuery.new
+exclusions = %w(afghanistan cambodia central-african-republic chad comoros
+ dominican-republic east-timor eritrea haiti kosovo laos lesotho
+ liberia madagascar montenegro paraguay samoa slovenia somalia
+ swaziland taiwan tajikistan western-sahara)
+no_embassies = %w(iran syria yemen)
+# Q1
multiple_choice :where_did_the_death_happen? do
- option :england_wales
- option :scotland_northern_ireland_abroad
-
save_input_as :where_death_happened
-
- next_node :did_the_person_die_at_home_hospital?
+ option :england_wales => :did_the_person_die_at_home_hospital?
+ option :scotland => :did_the_person_die_at_home_hospital?
+ option :northern_ireland => :did_the_person_die_at_home_hospital?
+ option :overseas => :which_country?
end
-
+# Q2
multiple_choice :did_the_person_die_at_home_hospital? do
option :at_home_hospital
option :elsewhere
-
calculate :died_at_home_hospital do
responses.last == 'at_home_hospital'
end
-
next_node :was_death_expected?
end
-
+# Q3
multiple_choice :was_death_expected? do
option :yes
option :no
-
+
calculate :death_expected do
responses.last == 'yes'
end
- calculate :content_sections do
+ next_node do |response|
+ if where_death_happened == 'overseas'
+ :which_country?
+ else
+ :uk_result
+ end
+ end
+end
+# Q4
+country_select :which_country? do
+ save_input_as :country
+ calculate :country_name do
+ SmartAnswer::Question::CountrySelect.countries.find { |c| c[:slug] == responses.last }[:name]
+ end
+ calculate :current_location do
+ data_query.registration_country_slug(responses.last) || responses.last
+ end
+ calculate :current_location_name do
+ SmartAnswer::Question::CountrySelect.countries.find { |c| c[:slug] == current_location }[:name]
+ end
+ next_node do |response|
+ if data_query.commonwealth_country?(response)
+ :commonwealth_result
+ elsif no_embassies.include?(response)
+ :no_embassy_result
+ else
+ :where_are_you_now?
+ end
+ end
+end
+# Q5
+multiple_choice :where_are_you_now? do
+ option :same_country => :embassy_result
+ option :another_country => :which_country_are_you_in_now?
+ option :back_in_the_uk => :fco_result
+
+ calculate :another_country do
+ responses.last == 'another_country'
+ end
+end
+# Q6
+country_select :which_country_are_you_in_now? do
+ save_input_as :current_location
+ calculate :current_location_name do
+ country_slug = data_query.registration_country_slug(responses.last)
+ SmartAnswer::Question::CountrySelect.countries.find { |c| c[:slug] == country_slug }[:name]
+ end
+ next_node :embassy_result
+end
+
+outcome :commonwealth_result
+outcome :no_embassy_result
+
+outcome :uk_result do
+ precalculate :content_sections do
sections = PhraseList.new
if where_death_happened == 'england_wales'
sections << :intro_ew << :who_can_register
@@ -38,15 +96,89 @@
sections << :need_to_tell_registrar
sections << :"documents_youll_get_ew_#{death_expected ? :expected : :unexpected}"
else
- sections << :intro_other
- sections << :intro_other_unexpected unless death_expected
- #who can register and documents you need sections are not needed for this type of outcome
- sections << :"documents_youll_get_other_#{death_expected ? :expected : :unexpected}"
+ sections << :"intro_#{where_death_happened}"
end
sections
end
+end
- next_node :done
+outcome :fco_result do
+ precalculate :embassy_high_commission_or_consulate do
+ data_query.has_high_commission?(current_location) ? "High commission" :
+ data_query.has_consulate?(current_location) ? "British embassy or consulate" :
+ "British embassy"
+ end
+ precalculate :registration_footnote do
+ exclusions.include?(country) ? '' : PhraseList.new(:reg_footnote)
+ end
end
-outcome :done
+outcome :embassy_result do
+ precalculate :embassy_high_commission_or_consulate do
+ data_query.has_high_commission?(current_location) ? "High commission" :
+ data_query.has_consulate?(current_location) ? "British embassy or consulate" :
+ "British embassy"
+ end
+
+ precalculate :clickbook do
+ result = ''
+ clickbook = data_query.clickbook(current_location)
+ i18n_prefix = "flow.register-a-death-v2"
+ unless clickbook.nil?
+ if clickbook.class == Hash
+ result = I18n.translate!("#{i18n_prefix}.phrases.multiple_clickbooks_intro") << "\n"
+ clickbook.each do |k,v|
+ result += %Q(- #{I18n.translate!(i18n_prefix + ".phrases.clickbook_link",
+ title: k, clickbook_url: v)})
+ end
+ else
+ result = I18n.translate!("#{i18n_prefix}.phrases.clickbook_link",
+ title: "Book an appointment online", clickbook_url: clickbook)
+ end
+ end
+
+ result
+ end
+
+ precalculate :postal_form_url do
+ data_query.death_postal_form(current_location)
+ end
+
+ precalculate :postal_return_form_url do
+ data_query.death_postal_return_form(current_location)
+ end
+
+ precalculate :postal do
+ if data_query.register_death_by_post?(current_location)
+ phrases = PhraseList.new(:postal_intro)
+ if postal_form_url
+ phrases << :postal_registration_by_form
+ else
+ phrases << :"postal_registration_#{current_location}"
+ end
+ phrases << :postal_delivery_form if postal_return_form_url
+ phrases
+ else
+ ''
+ end
+ end
+
+ precalculate :cash_only do
+ data_query.cash_only?(current_location) ? PhraseList.new(:cash_only) : ''
+ end
+
+ precalculate :embassy_address do
+ data = SmartAnswer::Calculators::PassportAndEmbassyDataQuery.new.find_embassy_data(current_location)
+ data.first['address'] if data
+ end
+
+ precalculate :footnote do
+ if exclusions.include?(country)
+ PhraseList.new(:footnote_exceptions)
+ elsif another_country
+ PhraseList.new(:footnote_another_country)
+ else
+ PhraseList.new(:footnote)
+ end
+ end
+end
View
353 test/integration/flows/register_a_death_test.rb
@@ -13,135 +13,350 @@ class RegisterADeathTest < ActiveSupport::TestCase
assert_current_node :where_did_the_death_happen?
end
- context "death happened in England or Wales" do
+ context "answer England or Wales" do
setup do
- add_response :england_wales
+ add_response 'england_wales'
end
-
- should "ask if the person died at home/in hospital or somewhere else" do
+ should "ask whether the death occurred at home or in hospital or elsewhere" do
assert_current_node :did_the_person_die_at_home_hospital?
end
-
- context "died at home/in hospital" do
+ context "answer home or in hospital" do
setup do
- add_response :at_home_hospital
+ add_response 'at_home_hospital'
end
-
- should "ask whether the death was expected" do
+ should "ask if the death was expected" do
assert_current_node :was_death_expected?
end
-
should "be outcome1 if death was expected" do
- add_response :yes
- assert_current_node :done
+ add_response 'yes'
+ assert_current_node :uk_result
assert_phrase_list :content_sections, [:intro_ew,
:who_can_register, :who_can_register_home_hospital,
:what_you_need_to_do_expected, :need_to_tell_registrar,
- :documents_youll_get_ew_expected
- ]
+ :documents_youll_get_ew_expected]
end
-
should "be outcome3 if death not expected" do
- add_response :no
- assert_current_node :done
+ add_response 'no'
+ assert_current_node :uk_result
assert_phrase_list :content_sections, [:intro_ew,
:who_can_register, :who_can_register_home_hospital,
:what_you_need_to_do_unexpected, :need_to_tell_registrar,
- :documents_youll_get_ew_unexpected
- ]
+ :documents_youll_get_ew_unexpected]
end
- end # at home/hospital
-
- context "died elsewhere" do
+ end
+ context "answer elsewhere" do
setup do
- add_response :elsewhere
+ add_response 'elsewhere'
end
-
- should "ask whether the death was expected" do
+ should "ask if the death was expected" do
assert_current_node :was_death_expected?
end
-
should "be outcome2 if death was expected" do
add_response :yes
- assert_current_node :done
+ assert_current_node :uk_result
assert_phrase_list :content_sections, [:intro_ew,
:who_can_register, :who_can_register_elsewhere,
:what_you_need_to_do_expected, :need_to_tell_registrar,
- :documents_youll_get_ew_expected
- ]
+ :documents_youll_get_ew_expected]
end
should "be outcome4 if death not expected" do
add_response :no
- assert_current_node :done
+ assert_current_node :uk_result
assert_phrase_list :content_sections, [:intro_ew,
:who_can_register, :who_can_register_elsewhere,
:what_you_need_to_do_unexpected, :need_to_tell_registrar,
- :documents_youll_get_ew_unexpected
- ]
+ :documents_youll_get_ew_unexpected]
end
- end # elsewhere
- end # England or Wales
+ end
+ end # England, Wales
- context "death happened in Scotland, Northern Ireland or abroad" do
+ context "answer Scotland" do
setup do
- add_response :scotland_northern_ireland_abroad
+ add_response 'scotland'
end
-
- should "ask if the person died at home/in hospital or somewhere else" do
+ should "ask whether the death occurred at home, in hospital or elsewhere" do
assert_current_node :did_the_person_die_at_home_hospital?
end
-
- context "died at home/in hospital" do
+ context "answer home or in hospital" do
setup do
- add_response :at_home_hospital
+ add_response 'at_home_hospital'
end
-
- should "ask whether the death was expected" do
+ should "ask if the death was expected" do
assert_current_node :was_death_expected?
end
-
should "be outcome5 if death was expected" do
add_response :yes
- assert_current_node :done
- assert_phrase_list :content_sections, [:intro_other,
- :documents_youll_get_other_expected
- ]
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_scotland]
end
-
should "be outcome7 if death not expected" do
add_response :no
- assert_current_node :done
- assert_phrase_list :content_sections, [:intro_other, :intro_other_unexpected,
- :documents_youll_get_other_unexpected
- ]
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_scotland]
end
- end # at home/hospital
-
- context "died elsewhere" do
+ end
+ context "answer elsewhere" do
setup do
- add_response :elsewhere
+ add_response 'elsewhere'
end
-
- should "ask whether the death was expected" do
+ should "ask if the death was expected" do
assert_current_node :was_death_expected?
end
+ should "be outcome6 if death was expected" do
+ add_response :yes
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_scotland]
+ end
+ should "be outcome8 if death not expected" do
+ add_response :no
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_scotland]
+ end
+ end
+ end # Scotland
+
+ context "answer Northern Ireland" do
+ setup do
+ add_response 'northern_ireland'
+ end
+ should "ask whether the death occurred at home, in hospital or elsewhere" do
+ assert_current_node :did_the_person_die_at_home_hospital?
+ end
+ context "answer home or in hospital" do
+ setup do
+ add_response 'at_home_hospital'
+ end
+ should "ask if the death was expected" do
+ assert_current_node :was_death_expected?
+ end
+ should "be outcome5 if death was expected" do
+ add_response :yes
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_northern_ireland]
+ end
+ should "be outcome7 if death not expected" do
+ add_response :no
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_northern_ireland]
+ end
+ end
+ context "answer elsewhere" do
+ setup do
+ add_response 'elsewhere'
+ end
+ should "ask if the death was expected" do
+ assert_current_node :was_death_expected?
+ end
should "be outcome6 if death was expected" do
add_response :yes
- assert_current_node :done
- assert_phrase_list :content_sections, [:intro_other,
- :documents_youll_get_other_expected
- ]
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_northern_ireland]
end
should "be outcome8 if death not expected" do
add_response :no
- assert_current_node :done
- assert_phrase_list :content_sections, [:intro_other, :intro_other_unexpected,
- :documents_youll_get_other_unexpected
- ]
+ assert_current_node :uk_result
+ assert_phrase_list :content_sections, [:intro_northern_ireland]
+ end
+ end
+ end # Northern Ireland
+
+ context "answer overseas" do
+ setup do
+ add_response 'overseas'
+ end
+
+ should "ask which country" do
+ assert_current_node :which_country?
+ end
+ context "answer Australia" do
+ setup do
+ add_response 'australia'
+ end
+ should "give the commonwealth result" do
+ assert_state_variable :country_name, "Australia"
+ assert_current_node :commonwealth_result
+ end
+ end # Australia (commonwealth country)
+ context "answer Spain" do
+ setup do
+ add_response 'spain'
+ end
+ should "ask where you are now" do
+ assert_state_variable :country_name, "Spain"
+ assert_state_variable :current_location_name, "Spain"
+ assert_current_node :where_are_you_now?
+ end
+ context "answer same country" do
+ setup do
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_phrase_list :footnote, [:footnote]
+ end
+ end # Answer embassy
+ context "answer fco office in the uk" do
+ setup do
+ add_response 'back_in_the_uk'
+ end
+ should "give the fco result and be done" do
+ assert_current_node :fco_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_phrase_list :registration_footnote, [:reg_footnote]
+ end
+ end # Answer fco
+ end # Answer Spain
+
+ context "answer Morocco" do
+ setup do
+ add_response 'morocco'
+ end
+ should "ask where you want to register the death" do
+ assert_state_variable :country_name, "Morocco"
+ assert_current_node :where_are_you_now?
+ end
+ context "answer fco office in the uk" do
+ setup do
+ add_response 'back_in_the_uk'
+ end
+ should "give the fco result and be done" do
+ assert_current_node :fco_result
+ end
+ end # Answer fco
+ end # Morocco
+
+ context "answer Argentina" do
+ setup do
+ add_response 'argentina'
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :clickbook, %Q([Book an appointment online](http://www.britishembassyinbsas.clickbook.net/ "Book an appointment at the British Embassy"){:rel="external"}\n)
+ end
+ end # Answer Argentina
+ context "answer China" do
+ setup do
+ add_response 'china'
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy or consulate"
+ assert_state_variable :clickbook, %Q(You can book an appointment at the British embassy or consulate in:
+
+- [Beijing](https://www.clickbook.net/dev/bc.nsf/sub/BritEmBeijing \"Book an appointment at the British Embassy\"){:rel=\"external\"}
+- [Shanghai](https://www.clickbook.net/dev/bc.nsf/sub/BritconShanghai \"Book an appointment at the British Embassy\"){:rel=\"external\"}
+- [Chongqing](https://www.clickbook.net/dev/bc.nsf/sub/BritConChongqing \"Book an appointment at the British Embassy\"){:rel=\"external\"}
+- [Guangzhou](https://www.clickbook.net/dev/bc.nsf/sub/BritConGuangzhou \"Book an appointment at the British Embassy\"){:rel=\"external\"}
+)
+ end
+ end # Answer China
+ context "answer Austria" do
+ setup do
+ add_response 'austria'
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :clickbook, ''
+ assert_state_variable :postal_form_url, "http://ukinaustria.fco.gov.uk/resources/en/pdf/pdf1/credit-card-form"
+ assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form]
+ end
+ end # Answer Austria
+ context "answer Belgium" do
+ setup do
+ add_response 'belgium'
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :clickbook, %Q([Book an appointment online](http://britishconsulate-gen.clickbook.net/ "Book an appointment at the British Embassy"){:rel="external"}\n)
+ assert_state_variable :postal_form_url, nil
+ assert_phrase_list :postal, [:postal_intro, :postal_registration_belgium]
+ end
+ end # Answer Belgium
+ context "answer Italy" do
+ setup do
+ add_response 'italy'
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :clickbook, %Q(You can book an appointment at the British embassy or consulate in:
+
+- [Rome](https://www.clickbook.net/dev/bc.nsf/sub/britishconsrome \"Book an appointment at the British Embassy\"){:rel=\"external\"}
+- [Milan](https://www.clickbook.net/dev/bc.nsf/sub/britishconsmilan \"Book an appointment at the British Embassy\"){:rel=\"external\"}
+)
+ assert_state_variable :postal_form_url, "http://ukinitaly.fco.gov.uk/resources/en/word/3121380/credit-card-authorisation-slip"
+ assert_state_variable :postal_return_form_url, "http://ukinitaly.fco.gov.uk/resources/en/word/3121380/Return-delivery-form"
+ assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form, :postal_delivery_form]
+ end
+ end # Answer Italy
+ context "death occurred in Andorra" do
+ setup do
+ add_response 'andorra'
+ add_response 'same_country'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :clickbook, ''
+ assert_state_variable :postal_form_url, "http://ukinspain.fco.gov.uk/resources/en/pdf/4758385/20090413_credit_card_form.pdf"
+ assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form, :postal_delivery_form]
+ assert_state_variable :country_name, "Andorra"
+ assert_state_variable :current_location, "spain"
+ end
+ end # Answer Andorra
+ context "death occurred in Andorra, but they are now in France" do
+ setup do
+ add_response 'andorra'
+ add_response 'another_country'
+ add_response 'france'
+ end
+ should "give the embassy result and be done" do
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :clickbook, %Q([Book an appointment online](http://ukinparis.clickbook.net/ "Book an appointment at the British Embassy"){:rel="external"}\n)
+ assert_state_variable :postal_form_url, "http://ukinfrance.fco.gov.uk/resources/en/word/consular/2012/death-registration-form"
+ assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form]
+ assert_state_variable :country_name, "Andorra"
+ assert_state_variable :current_location_name, "France"
+ assert_phrase_list :footnote, [:footnote_another_country]
+ end
+ end # Answer Andorra, now in France
+ context "answer Afghanistan" do
+ setup do
+ add_response 'afghanistan'
+ end
+ context "currently still in the country" do
+ should "give the embassy result and be done" do
+ add_response 'same_country'
+ assert_current_node :embassy_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_phrase_list :footnote, [:footnote_exceptions]
+ end
+ end
+ context "now back in the UK" do
+ should "give the FCO result and be done" do
+ add_response 'back_in_the_uk'
+ assert_current_node :fco_result
+ assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
+ assert_state_variable :registration_footnote, ''
+ end
+ end
+ end # Answer Afghanistan
+ context "answer Iran" do
+ should "give the no embassy result" do
+ add_response :no_embassy_result
end
- end # elsewhere
- end # Scotland, NI or abroad
+ end # Iran
+ end # Overseas
end
View
362 test/integration/flows/register_a_death_v2_test.rb
@@ -1,362 +0,0 @@
-# encoding: UTF-8
-require_relative '../../test_helper'
-require_relative 'flow_test_helper'
-
-class RegisterADeathV2Test < ActiveSupport::TestCase
- include FlowTestHelper
-
- setup do
- setup_for_testing_flow 'register-a-death-v2'
- end
-
- should "ask where the death happened" do
- assert_current_node :where_did_the_death_happen?
- end
-
- context "answer England or Wales" do
- setup do
- add_response 'england_wales'
- end
- should "ask whether the death occurred at home or in hospital or elsewhere" do
- assert_current_node :did_the_person_die_at_home_hospital?
- end
- context "answer home or in hospital" do
- setup do
- add_response 'at_home_hospital'
- end
- should "ask if the death was expected" do
- assert_current_node :was_death_expected?
- end
- should "be outcome1 if death was expected" do
- add_response 'yes'
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_ew,
- :who_can_register, :who_can_register_home_hospital,
- :what_you_need_to_do_expected, :need_to_tell_registrar,
- :documents_youll_get_ew_expected]
- end
- should "be outcome3 if death not expected" do
- add_response 'no'
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_ew,
- :who_can_register, :who_can_register_home_hospital,
- :what_you_need_to_do_unexpected, :need_to_tell_registrar,
- :documents_youll_get_ew_unexpected]
- end
- end
- context "answer elsewhere" do
- setup do
- add_response 'elsewhere'
- end
- should "ask if the death was expected" do
- assert_current_node :was_death_expected?
- end
- should "be outcome2 if death was expected" do
- add_response :yes
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_ew,
- :who_can_register, :who_can_register_elsewhere,
- :what_you_need_to_do_expected, :need_to_tell_registrar,
- :documents_youll_get_ew_expected]
- end
-
- should "be outcome4 if death not expected" do
- add_response :no
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_ew,
- :who_can_register, :who_can_register_elsewhere,
- :what_you_need_to_do_unexpected, :need_to_tell_registrar,
- :documents_youll_get_ew_unexpected]
- end
- end
- end # England, Wales
-
- context "answer Scotland" do
- setup do
- add_response 'scotland'
- end
- should "ask whether the death occurred at home, in hospital or elsewhere" do
- assert_current_node :did_the_person_die_at_home_hospital?
- end
- context "answer home or in hospital" do
- setup do
- add_response 'at_home_hospital'
- end
- should "ask if the death was expected" do
- assert_current_node :was_death_expected?
- end
- should "be outcome5 if death was expected" do
- add_response :yes
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_scotland]
- end
- should "be outcome7 if death not expected" do
- add_response :no
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_scotland]
- end
- end
- context "answer elsewhere" do
- setup do
- add_response 'elsewhere'
- end
- should "ask if the death was expected" do
- assert_current_node :was_death_expected?
- end
- should "be outcome6 if death was expected" do
- add_response :yes
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_scotland]
- end
-
- should "be outcome8 if death not expected" do
- add_response :no
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_scotland]
- end
- end
- end # Scotland
-
- context "answer Northern Ireland" do
- setup do
- add_response 'northern_ireland'
- end
- should "ask whether the death occurred at home, in hospital or elsewhere" do
- assert_current_node :did_the_person_die_at_home_hospital?
- end
- context "answer home or in hospital" do
- setup do
- add_response 'at_home_hospital'
- end
- should "ask if the death was expected" do
- assert_current_node :was_death_expected?
- end
- should "be outcome5 if death was expected" do
- add_response :yes
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_northern_ireland]
- end
- should "be outcome7 if death not expected" do
- add_response :no
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_northern_ireland]
- end
- end
- context "answer elsewhere" do
- setup do
- add_response 'elsewhere'
- end
- should "ask if the death was expected" do
- assert_current_node :was_death_expected?
- end
- should "be outcome6 if death was expected" do
- add_response :yes
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_northern_ireland]
- end
-
- should "be outcome8 if death not expected" do
- add_response :no
- assert_current_node :uk_result
- assert_phrase_list :content_sections, [:intro_northern_ireland]
- end
- end
- end # Northern Ireland
-
- context "answer overseas" do
- setup do
- add_response 'overseas'
- end
-
- should "ask which country" do
- assert_current_node :which_country?
- end
- context "answer Australia" do
- setup do
- add_response 'australia'
- end
- should "give the commonwealth result" do
- assert_state_variable :country_name, "Australia"
- assert_current_node :commonwealth_result
- end
- end # Australia (commonwealth country)
- context "answer Spain" do
- setup do
- add_response 'spain'
- end
- should "ask where you are now" do
- assert_state_variable :country_name, "Spain"
- assert_state_variable :current_location_name, "Spain"
- assert_current_node :where_are_you_now?
- end
- context "answer same country" do
- setup do
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_phrase_list :footnote, [:footnote]
- end
- end # Answer embassy
- context "answer fco office in the uk" do
- setup do
- add_response 'back_in_the_uk'
- end
- should "give the fco result and be done" do
- assert_current_node :fco_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_phrase_list :registration_footnote, [:reg_footnote]
- end
- end # Answer fco
- end # Answer Spain
-
- context "answer Morocco" do
- setup do
- add_response 'morocco'
- end
- should "ask where you want to register the death" do
- assert_state_variable :country_name, "Morocco"
- assert_current_node :where_are_you_now?
- end
- context "answer fco office in the uk" do
- setup do
- add_response 'back_in_the_uk'
- end
- should "give the fco result and be done" do
- assert_current_node :fco_result
- end
- end # Answer fco
- end # Morocco
-
- context "answer Argentina" do
- setup do
- add_response 'argentina'
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :clickbook, %Q([Book an appointment online](http://www.britishembassyinbsas.clickbook.net/ "Book an appointment at the British Embassy"){:rel="external"}\n)
- end
- end # Answer Argentina
- context "answer China" do
- setup do
- add_response 'china'
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy or consulate"
- assert_state_variable :clickbook, %Q(You can book an appointment at the British embassy or consulate in:
-
-- [Beijing](https://www.clickbook.net/dev/bc.nsf/sub/BritEmBeijing \"Book an appointment at the British Embassy\"){:rel=\"external\"}
-- [Shanghai](https://www.clickbook.net/dev/bc.nsf/sub/BritconShanghai \"Book an appointment at the British Embassy\"){:rel=\"external\"}
-- [Chongqing](https://www.clickbook.net/dev/bc.nsf/sub/BritConChongqing \"Book an appointment at the British Embassy\"){:rel=\"external\"}
-- [Guangzhou](https://www.clickbook.net/dev/bc.nsf/sub/BritConGuangzhou \"Book an appointment at the British Embassy\"){:rel=\"external\"}
-)
- end
- end # Answer China
- context "answer Austria" do
- setup do
- add_response 'austria'
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :clickbook, ''
- assert_state_variable :postal_form_url, "http://ukinaustria.fco.gov.uk/resources/en/pdf/pdf1/credit-card-form"
- assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form]
- end
- end # Answer Austria
- context "answer Belgium" do
- setup do
- add_response 'belgium'
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :clickbook, %Q([Book an appointment online](http://britishconsulate-gen.clickbook.net/ "Book an appointment at the British Embassy"){:rel="external"}\n)
- assert_state_variable :postal_form_url, nil
- assert_phrase_list :postal, [:postal_intro, :postal_registration_belgium]
- end
- end # Answer Belgium
- context "answer Italy" do
- setup do
- add_response 'italy'
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :clickbook, %Q(You can book an appointment at the British embassy or consulate in:
-
-- [Rome](https://www.clickbook.net/dev/bc.nsf/sub/britishconsrome \"Book an appointment at the British Embassy\"){:rel=\"external\"}
-- [Milan](https://www.clickbook.net/dev/bc.nsf/sub/britishconsmilan \"Book an appointment at the British Embassy\"){:rel=\"external\"}
-)
- assert_state_variable :postal_form_url, "http://ukinitaly.fco.gov.uk/resources/en/word/3121380/credit-card-authorisation-slip"
- assert_state_variable :postal_return_form_url, "http://ukinitaly.fco.gov.uk/resources/en/word/3121380/Return-delivery-form"
- assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form, :postal_delivery_form]
- end
- end # Answer Italy
- context "death occurred in Andorra" do
- setup do
- add_response 'andorra'
- add_response 'same_country'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :clickbook, ''
- assert_state_variable :postal_form_url, "http://ukinspain.fco.gov.uk/resources/en/pdf/4758385/20090413_credit_card_form.pdf"
- assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form, :postal_delivery_form]
- assert_state_variable :country_name, "Andorra"
- assert_state_variable :current_location, "spain"
- end
- end # Answer Andorra
- context "death occurred in Andorra, but they are now in France" do
- setup do
- add_response 'andorra'
- add_response 'another_country'
- add_response 'france'
- end
- should "give the embassy result and be done" do
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :clickbook, %Q([Book an appointment online](http://ukinparis.clickbook.net/ "Book an appointment at the British Embassy"){:rel="external"}\n)
- assert_state_variable :postal_form_url, "http://ukinfrance.fco.gov.uk/resources/en/word/consular/2012/death-registration-form"
- assert_phrase_list :postal, [:postal_intro, :postal_registration_by_form]
- assert_state_variable :country_name, "Andorra"
- assert_state_variable :current_location_name, "France"
- assert_phrase_list :footnote, [:footnote_another_country]
- end
- end # Answer Andorra, now in France
- context "answer Afghanistan" do
- setup do
- add_response 'afghanistan'
- end
- context "currently still in the country" do
- should "give the embassy result and be done" do
- add_response 'same_country'
- assert_current_node :embassy_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_phrase_list :footnote, [:footnote_exceptions]
- end
- end
- context "now back in the UK" do
- should "give the FCO result and be done" do
- add_response 'back_in_the_uk'
- assert_current_node :fco_result
- assert_state_variable :embassy_high_commission_or_consulate, "British embassy"
- assert_state_variable :registration_footnote, ''
- end
- end
- end # Answer Afghanistan
- context "answer Iran" do
- should "give the no embassy result" do
- add_response :no_embassy_result
- end
- end # Iran
- end # Overseas
-end
Please sign in to comment.
Something went wrong with that request. Please try again.