Skip to content

Commit

Permalink
EL-1732: Still show the how-to-aggregate screen for U18 flow, after…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
MazOneTwoOne authored Sep 20, 2024
1 parent 6547edf commit 74a88f3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/controllers/change_answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/lib/steps/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
36 changes: 36 additions & 0 deletions spec/flows/under_eighteen_flow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,49 @@
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")
fill_in_under_18_controlled_legal_rep_screen(choice: "Yes")
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")
Expand Down

0 comments on commit 74a88f3

Please sign in to comment.