From 74a88f3e4f9a8163ad61b7aed87456531d304382 Mon Sep 17 00:00:00 2001 From: MazOneTwoOne <76905544+MazOneTwoOne@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:12:12 +0100 Subject: [PATCH] EL-1732: Still show the `how-to-aggregate` screen for U18 flow, after changing answers (#1546) - add in tests for the behaviour we want to see - typos - add branching to in change answer controller to get `:how_to_aggregate` screen --- app/controllers/change_answers_controller.rb | 5 ++- app/lib/steps/helper.rb | 2 +- app/models/check.rb | 2 +- spec/flows/under_eighteen_flow_spec.rb | 36 ++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/app/controllers/change_answers_controller.rb b/app/controllers/change_answers_controller.rb index eff691327..bb210b1b6 100644 --- a/app/controllers/change_answers_controller.rb +++ b/app/controllers/change_answers_controller.rb @@ -9,6 +9,7 @@ def update # Note that this merge! has the side effect of altering the session data in the '@check' variable # that was loaded by our base class which looks quite awkward session_data.merge!(@form.attributes_for_export_to_session) + next_step = Steps::Helper.next_step_for(session_data, step) if @check.consistent? if Steps::Helper.last_step_in_group?(session_data, step) # if we have a 'check stops' block, it may have been removed even if we're consistent @@ -32,9 +33,11 @@ def update save_and_redirect_to_check_answers end else - next_step = Steps::Helper.next_step_for(session_data, step) redirect_to helpers.check_step_path_from_step(next_step, assessment_code) end + # this branch is neccessary to surface the ":how_to_aggregate" screen when changing answers + elsif step == :aggregated_means + redirect_to helpers.check_step_path_from_step(next_step, assessment_code) else redirect_to_next_question end diff --git a/app/lib/steps/helper.rb b/app/lib/steps/helper.rb index ffd79b9ee..ff105d496 100644 --- a/app/lib/steps/helper.rb +++ b/app/lib/steps/helper.rb @@ -77,7 +77,7 @@ def steps_for_section(session_data, section) # If you are working with the data you should call # this method to filter what is valid. def relevant_steps(session_data) - # if the list is *very* short (i.e. non-means) then use it rather then up to incopme + # if the list is *very* short (i.e. non-means) then use it rather then up to income if Steps::Logic.non_means_tested?(session_data) steps_list_for(session_data) elsif Steps::Logic.check_stops_at_gross_income?(session_data) diff --git a/app/models/check.rb b/app/models/check.rb index fe560046e..4b05abdee 100644 --- a/app/models/check.rb +++ b/app/models/check.rb @@ -142,7 +142,7 @@ def housing_benefit_relevant? housing_benefit_relevant end - # return true/false iff our data represents a consistent data set with no missing questions + # return true/false if our data represents a consistent data set with no missing questions # e.g. at least one 'employment' set if client is not unemployed # implement using data rather than Steps::Logic (although the knowledge is probably in Steps::Logic) def consistent? diff --git a/spec/flows/under_eighteen_flow_spec.rb b/spec/flows/under_eighteen_flow_spec.rb index c14cff3df..8be6425fa 100644 --- a/spec/flows/under_eighteen_flow_spec.rb +++ b/spec/flows/under_eighteen_flow_spec.rb @@ -435,6 +435,24 @@ confirm_screen("immigration_or_asylum") end + context "when doing a certificated check and then changing to a controlled" do + before do + fill_in_client_age_screen(choice: "Under 18") + fill_in_level_of_help_screen(choice: "Civil certificated") + confirm_screen(:check_answers) + within "#table-level_of_help" do + click_on "Change" + end + fill_in_level_of_help_screen(choice: "Civil controlled work or family mediation") + fill_in_under_18_controlled_legal_rep_screen(choice: "No") + fill_in_aggregated_means_screen(choice: "Yes") + end + + it "shows correct confirm screen" do + confirm_screen(:how_to_aggregate) + end + end + it "exits to Check your answers if it is Controlled Legal Representation work" do fill_in_client_age_screen(choice: "Under 18") fill_in_level_of_help_screen(choice: "Civil controlled work or family mediation") @@ -442,6 +460,24 @@ confirm_screen(:check_answers) end + context "when doing an U18 controlled CLR check and then changing to U18 controlled CLR to 'no'" do + before do + fill_in_client_age_screen(choice: "Under 18") + fill_in_level_of_help_screen(choice: "Civil controlled work or family mediation") + fill_in_under_18_controlled_legal_rep_screen(choice: "Yes") + confirm_screen(:check_answers) + within "#table-under_18_clr" do + click_on "Change" + end + fill_in_under_18_controlled_legal_rep_screen(choice: "No") + fill_in_aggregated_means_screen(choice: "Yes") + end + + it "shows correct confirm screen" do + confirm_screen(:how_to_aggregate) + end + end + it "exits early if regular income" do fill_in_client_age_screen(choice: "Under 18") fill_in_level_of_help_screen(choice: "Civil controlled work or family mediation")