From fffd0eefb0081f017adc73ea8935b35920f57b24 Mon Sep 17 00:00:00 2001 From: Barbara Slawinska Date: Tue, 3 Dec 2024 17:08:55 +0000 Subject: [PATCH 1/3] Update Winter Fuel Payment information in benefits if you live abroad This request is primarily about replacing this holding message with new questions which help users determine their eligibility for Winter Fuel Payment abroad this winter, but change 1 is about another simplification we can make. - Update all logic for the new flows for winter fuel payment including new logic for Ireland. - Fix existing tests for new flows - Add extra tests for new flow questions --- app/flows/uk_benefits_abroad_flow.rb | 86 +++++++++-- .../outcomes/wfp_maybe_outcome.erb | 4 + .../outcomes/wfp_not_eligible_outcome.erb | 2 +- .../born_before_23_September_1958.erb | 8 ++ ...r_partner_get_a_benefit_in_the_country.erb | 8 ++ ..._a_means_tested_benefit_in_the_country.erb | 21 +++ ...rtner_pay_contributions_to_the_country.erb | 8 ++ test/flows/uk_benefits_abroad_flow_test.rb | 134 +++++++++++++++--- 8 files changed, 240 insertions(+), 31 deletions(-) create mode 100644 app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb create mode 100644 app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb create mode 100644 app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb create mode 100644 app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb create mode 100644 app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb diff --git a/app/flows/uk_benefits_abroad_flow.rb b/app/flows/uk_benefits_abroad_flow.rb index e0d2d5990a0..2ef5d1d6ff6 100644 --- a/app/flows/uk_benefits_abroad_flow.rb +++ b/app/flows/uk_benefits_abroad_flow.rb @@ -104,16 +104,16 @@ def define else question :employer_paying_ni? # Q10, Q11, Q16 going_abroad and Q9, Q10, Q15 already_abroad end + when "winter_fuel_payment" - if calculator.country_eligible_for_winter_fuel_payment? - if calculator.country == "ireland" - question :is_british_or_irish? - else - question :worked_in_eea_or_switzerland? # A7 already_abroad - end + if calculator.country == "ireland" # going_abroad and already abroad + question :is_british_or_irish? + elsif calculator.already_abroad && calculator.country_eligible_for_winter_fuel_payment? + question :worked_in_eea_or_switzerland? else - outcome :wfp_not_eligible_outcome # A8 going_abroad and A6 already_abroad + outcome :wfp_not_eligible_outcome end + when "child_benefit" if calculator.eea_country? question :do_either_of_the_following_apply? # Q13 going_abroad and Q12 already_abroad @@ -579,7 +579,7 @@ def define when "jsa" outcome :jsa_eea_going_abroad_maybe_outcome when "winter_fuel_payment" - outcome :wfp_going_abroad_eea_maybe_outcome + question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) when "disability_benefits" @@ -603,7 +603,7 @@ def define when "jsa" outcome :jsa_eea_going_abroad_maybe_outcome when "winter_fuel_payment" - outcome :wfp_going_abroad_eea_maybe_outcome + question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) when "disability_benefits" @@ -624,6 +624,64 @@ def define end end + radio :born_before_23_September_1958? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + question :you_or_partner_get_a_benefit_in_the_country? + when "no" + outcome :wfp_not_eligible_outcome + end + end + end + + radio :you_or_partner_get_a_benefit_in_the_country? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + outcome :wfp_not_eligible_outcome + when "no" + question :you_or_partner_get_a_means_tested_benefit_in_the_country? + end + end + end + + # TODO: Is this still needed (any benefits other than winter fuel?) + radio :you_or_partner_pay_contributions_to_the_country? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + outcome :wfp_not_eligible_outcome + when "no" + question :you_or_partner_get_a_means_tested_benefit_in_the_country? + end + end + end + + radio :you_or_partner_get_a_means_tested_benefit_in_the_country? do + option :yes + option :no + + next_node do |response| + case response + when "yes" + outcome :wfp_maybe_outcome + when "no" + outcome :wfp_not_eligible_outcome + end + end + end + + # TODO: Do we need to check this?? radio :is_british_or_irish? do option :yes option :no @@ -635,14 +693,19 @@ def define when "jsa" outcome :jsa_ireland_outcome when "winter_fuel_payment" - outcome :wfp_ireland_outcome + # outcome :wfp_ireland_outcome + question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) when "disability_benefits" outcome :db_going_abroad_ireland_outcome end when "no" - question :worked_in_eea_or_switzerland? + if calculator.benefit == "winter_fuel_payment" && calculator.going_abroad + outcome :wfp_not_eligible_outcome + else + question :worked_in_eea_or_switzerland? + end end end end @@ -716,6 +779,7 @@ def define outcome :wfp_going_abroad_eea_maybe_outcome outcome :wfp_ireland_outcome + outcome :wfp_maybe_outcome outcome :db_going_abroad_ireland_outcome end diff --git a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb new file mode 100644 index 00000000000..656ff0de847 --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_maybe_outcome.erb @@ -0,0 +1,4 @@ +<% govspeak_for :body do %> + You might be eligible for Winter Fuel Payment. + Find out [how to apply for Winter Fuel Payment if you live abroad](https://www.gov.uk/winter-fuel-payment/if-you-live-abroad). +<% end %> diff --git a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb index e9d5ee2122d..d5d43367f16 100644 --- a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb +++ b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_not_eligible_outcome.erb @@ -1,3 +1,3 @@ <% govspeak_for :body do %> - You cannot get a [Winter Fuel Payment](/winter-fuel-payment). + You cannot get a [Winter Fuel Payment](/winter-fuel-payment) abroad. <% end %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb b/app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb new file mode 100644 index 00000000000..98937ec1542 --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/born_before_23_September_1958.erb @@ -0,0 +1,8 @@ +<% text_for :title do %> + Were you born before 23 September 1958? +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb new file mode 100644 index 00000000000..304df74a5fb --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_benefit_in_the_country.erb @@ -0,0 +1,8 @@ +<% text_for :title do %> + Do you or your partner get a pension or a benefit based on your work contributions in the country you are living in? +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb new file mode 100644 index 00000000000..1cd7215e145 --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_get_a_means_tested_benefit_in_the_country.erb @@ -0,0 +1,21 @@ +<% text_for :title do %> + Did you or your partner get a means-tested benefit in the country you are living in between 16 and 22 September 2024? +<% end %> + +<% govspeak_for :body do %> + You must have been getting a benefit from the country you live in that’s equivalent to: + + - Pension Credit + - Universal Credit + - Income-related Employment and Support Allowance (ESA) + - Income-based Jobseeker’s Allowance (JSA) + - Income Support + - Working Tax Credit + - Child Tax Credit + +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb new file mode 100644 index 00000000000..a58619e09bc --- /dev/null +++ b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb @@ -0,0 +1,8 @@ +<% text_for :title do %> + Do you or your partner work or pay contributions (similar to [National Insurance](https://www.gov.uk/national-insurance)) to the country you are living in? +<% end %> + +<% options( + "yes": "Yes", + "no": "No" +) %> diff --git a/test/flows/uk_benefits_abroad_flow_test.rb b/test/flows/uk_benefits_abroad_flow_test.rb index 1b590e59b0d..f8c497aaf45 100644 --- a/test/flows/uk_benefits_abroad_flow_test.rb +++ b/test/flows/uk_benefits_abroad_flow_test.rb @@ -161,17 +161,40 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase setup do add_responses which_benefit?: "winter_fuel_payment" end + context "already abroad" do + setup do + add_responses going_or_already_abroad?: "already_abroad" + end - should "have next node of is_british_or_irish? for an 'ireland' response" do - assert_next_node :is_british_or_irish?, for_response: "ireland" - end + should "have next node of is_british_or_irish? for an 'ireland' response" do + assert_next_node :is_british_or_irish?, for_response: "ireland" + end - should "have a next node of worked_in_eea_or_switzerland? for any EEA country response except ireland" do - assert_next_node :worked_in_eea_or_switzerland?, for_response: "liechtenstein" + should "have a next node of worked_in_eea_or_switzerland? for any EEA country response except ireland" do + assert_next_node :worked_in_eea_or_switzerland?, for_response: "liechtenstein" + end + + should "have a next node of wfp_not_eligible_outcome for any non-EEA country response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "australia" + end end - should "have a next node of wfp_not_eligible_outcome for any non-EEA country response" do - assert_next_node :wfp_not_eligible_outcome, for_response: "australia" + context "going abroad" do + setup do + add_responses going_or_already_abroad?: "going_abroad" + end + + should "have next node of is_british_or_irish? for an 'ireland' response" do + assert_next_node :is_british_or_irish?, for_response: "ireland" + end + + should "have a next node of wfp_not_eligible_outcome for any EEA country other than ireland" do + assert_next_node :wfp_not_eligible_outcome, for_response: "liechtenstein" + end + + should "have a next node of wfp_not_eligible_outcome for any non-EEA country response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "australia" + end end end @@ -929,9 +952,9 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" end - should "have a next node of wfp_going_abroad_eea_maybe_outcome for a 'before_jan_2021' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :wfp_going_abroad_eea_maybe_outcome, for_response: "before_jan_2021" + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment" do + add_responses which_benefit?: "winter_fuel_payment", going_or_already_abroad?: "already_abroad" + assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" end should "have a next node of esa_going_abroad_eea_outcome for a 'before_jan_2021' response if benefit is esa and going_abroad" do @@ -960,6 +983,7 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_already_abroad_eea_outcome, for_response: "before_jan_2021" end + # TODO: Should we cycle through the different benefits for the following tests? should "have a next node of parents_lived_in_eea_or_switzerland? for a 'after_jan_2021' response" do assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: "after_jan_2021" end @@ -988,9 +1012,10 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" end - should "have a next node of wfp_going_abroad_eea_maybe_outcome for a 'before_jan_2021' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :wfp_going_abroad_eea_maybe_outcome, for_response: "before_jan_2021" + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment and already abroad" do + add_responses which_benefit?: "winter_fuel_payment", + going_or_already_abroad?: "already_abroad" + assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" end should "have a next node of esa_going_abroad_eea_outcome for a 'before_jan_2021' response if benefit is esa and going_abroad" do @@ -1024,8 +1049,9 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_not_entitled_outcome, for_response: response end - should "have a next node of wfp_not_eligible_outcome for a '#{response}' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" + should "have a next node of wfp_not_eligible_outcome for a '#{response}' response if benefit is winter_fuel_payment and already abroad" do + add_responses which_benefit?: "winter_fuel_payment", + going_or_already_abroad?: "already_abroad" assert_next_node :wfp_not_eligible_outcome, for_response: response end @@ -1075,18 +1101,18 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_ireland_outcome, for_response: "yes" end - should "have a next node of wfp_ireland_outcome for a 'yes' response if benefit is winter_fuel_payment" do + should "have a next node of born_before_23_September_1958? for a 'yes' response if benefit is winter_fuel_payment" do add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :wfp_ireland_outcome, for_response: "yes" + assert_next_node :born_before_23_September_1958?, for_response: "yes" end - should "have a next node of esa_going_abroad_eea_outcome for a 'yes' response if benefit is winter_fuel_payment and going_abroad" do + should "have a next node of esa_going_abroad_eea_outcome for a 'yes' response if benefit is esa and going_abroad" do add_responses which_benefit?: "esa", esa_how_long_abroad?: "esa_more_than_a_year" assert_next_node :esa_going_abroad_eea_outcome, for_response: "yes" end - should "have a next node of esa_already_abroad_eea_outcome for a 'yes' response if benefit is winter_fuel_payment and already_abroad" do + should "have a next node of esa_already_abroad_eea_outcome for a 'yes' response if benefit is esa and already_abroad" do add_responses going_or_already_abroad?: "already_abroad", which_benefit?: "esa", esa_how_long_abroad?: "esa_more_than_a_year" @@ -1099,12 +1125,82 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_going_abroad_eea_outcome, for_response: "before_jan_2021" end + should "have a next node of wfp_outcome_not_eligible for a 'no' response if benefit is winter_fuel_payment and going abroad" do + add_responses which_benefit?: "winter_fuel_payment" + # going_or_already_abroad?: "going_abroad" + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + should "have a next node of worked_in_eea_or_switzerland? for a 'no' response" do assert_next_node :worked_in_eea_or_switzerland?, for_response: "no" end end end + context "question: born_before_23_September_1958? for winter_fuel_payment" do + setup do + testing_node :born_before_23_September_1958? + add_responses going_or_already_abroad?: "already_abroad", + which_benefit?: "winter_fuel_payment", + which_country?: "ireland", + is_british_or_irish?: "yes" + end + + context "next_node" do + should "have a next node of wfp_not_eligible_outcome for a 'no' response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do + assert_next_node :you_or_partner_get_a_benefit_in_the_country?, for_response: "yes" + end + end + end + + context "question: you_or_partner_get_a_benefit_in_the_country? for winter_fuel_payment" do + setup do + testing_node :you_or_partner_get_a_benefit_in_the_country? + add_responses which_benefit?: "winter_fuel_payment", + going_or_already_abroad?: "already_abroad", + which_country?: "ireland", + is_british_or_irish?: "yes", + born_before_23_September_1958?: "yes" + end + + context "next_node" do + should "have a next node of wfp_not_eligible_outcome for a 'yes' response if benefit is winter fuel" do + assert_next_node :wfp_not_eligible_outcome, for_response: "yes" + end + + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'no' response" do + assert_next_node :you_or_partner_get_a_means_tested_benefit_in_the_country?, for_response: 'no' + end + end + end + + context "question: you_or_partner_get_a_means_tested_benefit_in_the_country? for winter_fuel_payment" do + setup do + testing_node :you_or_partner_get_a_means_tested_benefit_in_the_country? + add_responses which_benefit?: "winter_fuel_payment", + going_or_already_abroad?: "already_abroad", + which_country?: "ireland", + is_british_or_irish?: "yes", + born_before_23_September_1958?: "yes", + you_or_partner_get_a_benefit_in_the_country?: "no" + end + + context "next_node" do + should "have a next node of wfp_not_eligible_outcome for a 'no' response if benefit is winter fuel" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do + assert_next_node :wfp_maybe_outcome, for_response: 'yes' + end + end + end + + context "outcome: bb_already_abroad_ss_outcome" do setup do testing_node :bb_already_abroad_ss_outcome From c3676a71d21077e1673283beed44fac45ce01b8b Mon Sep 17 00:00:00 2001 From: Helen Pickavance Date: Tue, 7 Jan 2025 16:47:53 +0000 Subject: [PATCH 2/3] Update logic for EEA countries as per request - Add/update tests for new questions and altered routes --- app/flows/uk_benefits_abroad_flow.rb | 5 +- test/flows/uk_benefits_abroad_flow_test.rb | 159 ++++++++++++--------- 2 files changed, 91 insertions(+), 73 deletions(-) diff --git a/app/flows/uk_benefits_abroad_flow.rb b/app/flows/uk_benefits_abroad_flow.rb index 2ef5d1d6ff6..9b54b74ebdf 100644 --- a/app/flows/uk_benefits_abroad_flow.rb +++ b/app/flows/uk_benefits_abroad_flow.rb @@ -106,9 +106,10 @@ def define end when "winter_fuel_payment" - if calculator.country == "ireland" # going_abroad and already abroad + # The following are all the same for going_abroad and already abroad + if calculator.country == "ireland" question :is_british_or_irish? - elsif calculator.already_abroad && calculator.country_eligible_for_winter_fuel_payment? + elsif calculator.country_eligible_for_winter_fuel_payment? question :worked_in_eea_or_switzerland? else outcome :wfp_not_eligible_outcome diff --git a/test/flows/uk_benefits_abroad_flow_test.rb b/test/flows/uk_benefits_abroad_flow_test.rb index f8c497aaf45..6c6db36f1d6 100644 --- a/test/flows/uk_benefits_abroad_flow_test.rb +++ b/test/flows/uk_benefits_abroad_flow_test.rb @@ -40,8 +40,10 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of which_benefit? for any response" do - assert_next_node :which_benefit?, for_response: "going_abroad" + %w[going_abroad already_abroad].each do |response| + should "have a next node of which_benefit? for a '#{response}' response" do + assert_next_node :which_benefit?, for_response: response + end end end end @@ -58,7 +60,14 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase context "next_node" do %w[winter_fuel_payment maternity_benefits child_benefit ssp bereavement_benefits jsa].each do |benefit| - should "have a next node of which_country? for a '#{benefit}' response" do + should "have a next node of which_country? for a '#{benefit}' response if going_abroad" do + assert_next_node :which_country?, for_response: benefit + end + + # Repeat of above for an 'already_abroad' response + # TODO: Could this could be refactored to use contexts for the different responses? + should "have a next node of which_country? for a '#{benefit}' response if already_abroad" do + add_responses going_or_already_abroad?: "already_abroad" assert_next_node :which_country?, for_response: benefit end end @@ -67,6 +76,7 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :iidb_already_claiming?, for_response: "iidb" end + # TODO: Example - what is the response needed for ESA and already_abroad? This is only testing going_abroad. should "have a next node of esa_how_long_abroad? for an 'esa' response" do assert_next_node :esa_how_long_abroad?, for_response: "esa" end @@ -161,38 +171,20 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase setup do add_responses which_benefit?: "winter_fuel_payment" end - context "already abroad" do - setup do - add_responses going_or_already_abroad?: "already_abroad" - end - should "have next node of is_british_or_irish? for an 'ireland' response" do + %w[going_abroad already_abroad].each do |location| + should "have next node of is_british_or_irish? for an 'ireland' response if #{location}" do + add_responses going_or_already_abroad?: location assert_next_node :is_british_or_irish?, for_response: "ireland" end - should "have a next node of worked_in_eea_or_switzerland? for any EEA country response except ireland" do + should "have a next node of worked_in_eea_or_switzerland? for any EEA country response except ireland if #{location}" do + add_responses going_or_already_abroad?: location assert_next_node :worked_in_eea_or_switzerland?, for_response: "liechtenstein" end - should "have a next node of wfp_not_eligible_outcome for any non-EEA country response" do - assert_next_node :wfp_not_eligible_outcome, for_response: "australia" - end - end - - context "going abroad" do - setup do - add_responses going_or_already_abroad?: "going_abroad" - end - - should "have next node of is_british_or_irish? for an 'ireland' response" do - assert_next_node :is_british_or_irish?, for_response: "ireland" - end - - should "have a next node of wfp_not_eligible_outcome for any EEA country other than ireland" do - assert_next_node :wfp_not_eligible_outcome, for_response: "liechtenstein" - end - - should "have a next node of wfp_not_eligible_outcome for any non-EEA country response" do + should "have a next node of wfp_not_eligible_outcome for any non-EEA country response if #{location}" do + add_responses going_or_already_abroad?: location assert_next_node :wfp_not_eligible_outcome, for_response: "australia" end end @@ -948,13 +940,18 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of jsa_eea_going_abroad_maybe_outcome for a 'before_jan_2021' response if benefit is jsa" do - assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" - end + context "winter_fuel_payment" do + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment" do + add_responses which_benefit?: "winter_fuel_payment" + assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" + end - should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment", going_or_already_abroad?: "already_abroad" - assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" + %w[no after_jan_2021].each do |response| + should "have a next node of parents_lived_in_eea_or_switzerland? for a #{response} response if benefit is winter_fuel_payment" do + add_responses which_benefit?: "winter_fuel_payment" + assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: response + end + end end should "have a next node of esa_going_abroad_eea_outcome for a 'before_jan_2021' response if benefit is esa and going_abroad" do @@ -984,11 +981,15 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end # TODO: Should we cycle through the different benefits for the following tests? - should "have a next node of parents_lived_in_eea_or_switzerland? for a 'after_jan_2021' response" do + should "have a next node of jsa_eea_going_abroad_maybe_outcome for a 'before_jan_2021' response if benefit is jsa" do + assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" + end + + should "have a next node of parents_lived_in_eea_or_switzerland? for a 'after_jan_2021' response if benefit is jsa" do assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: "after_jan_2021" end - should "have a next node of parents_lived_in_eea_or_switzerland? for a 'no' response" do + should "have a next node of parents_lived_in_eea_or_switzerland? for a 'no' response if benefit is jsa" do assert_next_node :parents_lived_in_eea_or_switzerland?, for_response: "no" end end @@ -1012,12 +1013,6 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" end - should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment and already abroad" do - add_responses which_benefit?: "winter_fuel_payment", - going_or_already_abroad?: "already_abroad" - assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" - end - should "have a next node of esa_going_abroad_eea_outcome for a 'before_jan_2021' response if benefit is esa and going_abroad" do add_responses which_benefit?: "esa", esa_how_long_abroad?: "esa_more_than_a_year" @@ -1044,14 +1039,20 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_already_abroad_eea_outcome, for_response: "before_jan_2021" end + context "winter_fuel_payment" do + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment and going_abroad" do + add_responses which_benefit?: "winter_fuel_payment" + assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" + end + end + %w[after_jan_2021 no].each do |response| should "have a next node of jsa_not_entitled_outcome for a '#{response}' response if benefit is jsa" do assert_next_node :jsa_not_entitled_outcome, for_response: response end - should "have a next node of wfp_not_eligible_outcome for a '#{response}' response if benefit is winter_fuel_payment and already abroad" do - add_responses which_benefit?: "winter_fuel_payment", - going_or_already_abroad?: "already_abroad" + should "have a next node of wfp_not_eligible_outcome for a '#{response}' response if benefit is winter_fuel_payment and going_abroad" do + add_responses which_benefit?: "winter_fuel_payment" assert_next_node :wfp_not_eligible_outcome, for_response: response end @@ -1097,13 +1098,30 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of jsa_ireland_outcome for a 'yes' response if benefit is jsa" do - assert_next_node :jsa_ireland_outcome, for_response: "yes" + context "winter_fuel_payment" do + setup do + add_responses which_benefit?: "winter_fuel_payment" + end + + %w[going_abroad already_abroad].each do |location| + should "have a next node of born_before_23_September_1958? for a 'yes' response if benefit is winter_fuel_payment and #{location}" do + add_responses going_or_already_abroad?: location + assert_next_node :born_before_23_September_1958?, for_response: "yes" + end + end + + should "have a next node of wfp_outcome_not_eligible for a 'no' response if benefit is winter_fuel_payment and going abroad" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" + end + + should "have a next node of worked_in_eea_or_switzerland? for a 'no' response if benefit is winter_fuel_payment and already abroad" do + add_responses going_or_already_abroad?: "already_abroad" + assert_next_node :worked_in_eea_or_switzerland?, for_response: "no" + end end - should "have a next node of born_before_23_September_1958? for a 'yes' response if benefit is winter_fuel_payment" do - add_responses which_benefit?: "winter_fuel_payment" - assert_next_node :born_before_23_September_1958?, for_response: "yes" + should "have a next node of jsa_ireland_outcome for a 'yes' response if benefit is jsa" do + assert_next_node :jsa_ireland_outcome, for_response: "yes" end should "have a next node of esa_going_abroad_eea_outcome for a 'yes' response if benefit is esa and going_abroad" do @@ -1125,12 +1143,6 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_going_abroad_eea_outcome, for_response: "before_jan_2021" end - should "have a next node of wfp_outcome_not_eligible for a 'no' response if benefit is winter_fuel_payment and going abroad" do - add_responses which_benefit?: "winter_fuel_payment" - # going_or_already_abroad?: "going_abroad" - assert_next_node :wfp_not_eligible_outcome, for_response: "no" - end - should "have a next node of worked_in_eea_or_switzerland? for a 'no' response" do assert_next_node :worked_in_eea_or_switzerland?, for_response: "no" end @@ -1140,40 +1152,46 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase context "question: born_before_23_September_1958? for winter_fuel_payment" do setup do testing_node :born_before_23_September_1958? - add_responses going_or_already_abroad?: "already_abroad", + add_responses going_or_already_abroad?: "going_abroad", which_benefit?: "winter_fuel_payment", which_country?: "ireland", is_british_or_irish?: "yes" end - context "next_node" do - should "have a next node of wfp_not_eligible_outcome for a 'no' response" do - assert_next_node :wfp_not_eligible_outcome, for_response: "no" - end + should "render the question" do + assert_rendered_question + end - should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do - assert_next_node :you_or_partner_get_a_benefit_in_the_country?, for_response: "yes" - end + should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do + assert_next_node :you_or_partner_get_a_benefit_in_the_country?, for_response: "yes" + end + + should "have a next node of wfp_not_eligible_outcome for a 'no' response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "no" end end context "question: you_or_partner_get_a_benefit_in_the_country? for winter_fuel_payment" do setup do testing_node :you_or_partner_get_a_benefit_in_the_country? - add_responses which_benefit?: "winter_fuel_payment", - going_or_already_abroad?: "already_abroad", + add_responses going_or_already_abroad?: "already_abroad", + which_benefit?: "winter_fuel_payment", which_country?: "ireland", is_british_or_irish?: "yes", born_before_23_September_1958?: "yes" end + should "render the question" do + assert_rendered_question + end + context "next_node" do - should "have a next node of wfp_not_eligible_outcome for a 'yes' response if benefit is winter fuel" do + should "have a next node of wfp_not_eligible_outcome for a 'yes' response" do assert_next_node :wfp_not_eligible_outcome, for_response: "yes" end should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'no' response" do - assert_next_node :you_or_partner_get_a_means_tested_benefit_in_the_country?, for_response: 'no' + assert_next_node :you_or_partner_get_a_means_tested_benefit_in_the_country?, for_response: "no" end end end @@ -1190,17 +1208,16 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "next_node" do - should "have a next node of wfp_not_eligible_outcome for a 'no' response if benefit is winter fuel" do + should "have a next node of wfp_not_eligible_outcome for a 'no' response" do assert_next_node :wfp_not_eligible_outcome, for_response: "no" end should "have a next node of you_or_partner_get_a_benefit_in_the_country? for a 'yes' response" do - assert_next_node :wfp_maybe_outcome, for_response: 'yes' + assert_next_node :wfp_maybe_outcome, for_response: "yes" end end end - context "outcome: bb_already_abroad_ss_outcome" do setup do testing_node :bb_already_abroad_ss_outcome From 6b553cc5a8c3be3b73cd3e671bcec11fd5c1d273 Mon Sep 17 00:00:00 2001 From: Helen Pickavance Date: Thu, 9 Jan 2025 14:09:17 +0000 Subject: [PATCH 3/3] Clean up of unused code for previous flow logic --- app/flows/uk_benefits_abroad_flow.rb | 20 +---------- .../wfp_going_abroad_eea_maybe_outcome.erb | 5 --- ...rtner_pay_contributions_to_the_country.erb | 8 ----- test/flows/uk_benefits_abroad_flow_test.rb | 36 +++++++------------ 4 files changed, 13 insertions(+), 56 deletions(-) delete mode 100644 app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb delete mode 100644 app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb diff --git a/app/flows/uk_benefits_abroad_flow.rb b/app/flows/uk_benefits_abroad_flow.rb index 9b54b74ebdf..9efe1fd0bc5 100644 --- a/app/flows/uk_benefits_abroad_flow.rb +++ b/app/flows/uk_benefits_abroad_flow.rb @@ -653,21 +653,6 @@ def define end end - # TODO: Is this still needed (any benefits other than winter fuel?) - radio :you_or_partner_pay_contributions_to_the_country? do - option :yes - option :no - - next_node do |response| - case response - when "yes" - outcome :wfp_not_eligible_outcome - when "no" - question :you_or_partner_get_a_means_tested_benefit_in_the_country? - end - end - end - radio :you_or_partner_get_a_means_tested_benefit_in_the_country? do option :yes option :no @@ -682,7 +667,6 @@ def define end end - # TODO: Do we need to check this?? radio :is_british_or_irish? do option :yes option :no @@ -694,7 +678,6 @@ def define when "jsa" outcome :jsa_ireland_outcome when "winter_fuel_payment" - # outcome :wfp_ireland_outcome question :born_before_23_September_1958? when "esa" outcome(calculator.going_abroad ? :esa_going_abroad_eea_outcome : :esa_already_abroad_eea_outcome) @@ -714,7 +697,6 @@ def define outcome :pension_going_abroad_outcome # A2 going_abroad outcome :jsa_social_security_going_abroad_outcome # A6 going_abroad outcome :jsa_not_entitled_outcome # A7 going_abroad and A5 already_abroad - outcome :wfp_not_eligible_outcome # A8 going_abroad and A6 already_abroad outcome :maternity_benefits_maternity_allowance_outcome # A10 going_abroad and A8 already_abroad outcome :maternity_benefits_social_security_going_abroad_outcome # A12 going_abroad outcome :maternity_benefits_not_entitled_outcome # A13 going_abroad and A11 already_abroad @@ -778,9 +760,9 @@ def define outcome :jsa_eea_going_abroad_maybe_outcome outcome :jsa_ireland_outcome - outcome :wfp_going_abroad_eea_maybe_outcome outcome :wfp_ireland_outcome outcome :wfp_maybe_outcome + outcome :wfp_not_eligible_outcome outcome :db_going_abroad_ireland_outcome end diff --git a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb b/app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb deleted file mode 100644 index dd537f30119..00000000000 --- a/app/flows/uk_benefits_abroad_flow/outcomes/wfp_going_abroad_eea_maybe_outcome.erb +++ /dev/null @@ -1,5 +0,0 @@ -<% govspeak_for :body do %> -Eligibility for Winter Fuel Payment has changed for winter 2024. - -[Read the Winter Fuel Payment if you live abroad guidance](https://www.gov.uk/winter-fuel-payment/if-you-live-abroad) for more information. -<% end %> diff --git a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb b/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb deleted file mode 100644 index a58619e09bc..00000000000 --- a/app/flows/uk_benefits_abroad_flow/questions/you_or_partner_pay_contributions_to_the_country.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% text_for :title do %> - Do you or your partner work or pay contributions (similar to [National Insurance](https://www.gov.uk/national-insurance)) to the country you are living in? -<% end %> - -<% options( - "yes": "Yes", - "no": "No" -) %> diff --git a/test/flows/uk_benefits_abroad_flow_test.rb b/test/flows/uk_benefits_abroad_flow_test.rb index 6c6db36f1d6..f992ca604a5 100644 --- a/test/flows/uk_benefits_abroad_flow_test.rb +++ b/test/flows/uk_benefits_abroad_flow_test.rb @@ -1,6 +1,7 @@ require "test_helper" require "support/flow_test_helper" +# noinspection RubyResolve class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase include FlowTestHelper @@ -63,20 +64,12 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase should "have a next node of which_country? for a '#{benefit}' response if going_abroad" do assert_next_node :which_country?, for_response: benefit end - - # Repeat of above for an 'already_abroad' response - # TODO: Could this could be refactored to use contexts for the different responses? - should "have a next node of which_country? for a '#{benefit}' response if already_abroad" do - add_responses going_or_already_abroad?: "already_abroad" - assert_next_node :which_country?, for_response: benefit - end end should "have a next node of iidb_already_claiming? for an 'iidb' response" do assert_next_node :iidb_already_claiming?, for_response: "iidb" end - # TODO: Example - what is the response needed for ESA and already_abroad? This is only testing going_abroad. should "have a next node of esa_how_long_abroad? for an 'esa' response" do assert_next_node :esa_how_long_abroad?, for_response: "esa" end @@ -172,21 +165,16 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase add_responses which_benefit?: "winter_fuel_payment" end - %w[going_abroad already_abroad].each do |location| - should "have next node of is_british_or_irish? for an 'ireland' response if #{location}" do - add_responses going_or_already_abroad?: location - assert_next_node :is_british_or_irish?, for_response: "ireland" - end + should "have next node of is_british_or_irish? for an 'ireland' response" do + assert_next_node :is_british_or_irish?, for_response: "ireland" + end - should "have a next node of worked_in_eea_or_switzerland? for any EEA country response except ireland if #{location}" do - add_responses going_or_already_abroad?: location - assert_next_node :worked_in_eea_or_switzerland?, for_response: "liechtenstein" - end + should "have a next node of worked_in_eea_or_switzerland? for any EEA country response except ireland" do + assert_next_node :worked_in_eea_or_switzerland?, for_response: "liechtenstein" + end - should "have a next node of wfp_not_eligible_outcome for any non-EEA country response if #{location}" do - add_responses going_or_already_abroad?: location - assert_next_node :wfp_not_eligible_outcome, for_response: "australia" - end + should "have a next node of wfp_not_eligible_outcome for any non-EEA country response" do + assert_next_node :wfp_not_eligible_outcome, for_response: "australia" end end @@ -980,7 +968,7 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :db_already_abroad_eea_outcome, for_response: "before_jan_2021" end - # TODO: Should we cycle through the different benefits for the following tests? + # TODO: Do we need to cycle through the different benefits for the following tests? should "have a next node of jsa_eea_going_abroad_maybe_outcome for a 'before_jan_2021' response if benefit is jsa" do assert_next_node :jsa_eea_going_abroad_maybe_outcome, for_response: "before_jan_2021" end @@ -1040,7 +1028,7 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase end context "winter_fuel_payment" do - should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment and going_abroad" do + should "have a next node of born_before_23_September_1958 for a 'before_jan_2021' response if benefit is winter_fuel_payment" do add_responses which_benefit?: "winter_fuel_payment" assert_next_node :born_before_23_September_1958?, for_response: "before_jan_2021" end @@ -1051,7 +1039,7 @@ class UkBenefitsAbroadFlowTest < ActiveSupport::TestCase assert_next_node :jsa_not_entitled_outcome, for_response: response end - should "have a next node of wfp_not_eligible_outcome for a '#{response}' response if benefit is winter_fuel_payment and going_abroad" do + should "have a next node of wfp_not_eligible_outcome for a '#{response}' response if benefit is winter_fuel_payment" do add_responses which_benefit?: "winter_fuel_payment" assert_next_node :wfp_not_eligible_outcome, for_response: response end