diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index c6cad74a3..9e9e7a3f8 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -132,22 +132,13 @@ private def get_next_page_path(form, previous_page, responses_for_page = {}) questions_for_page = form.questions_for_page(previous_page) questions_for_page.each do |question, content| - if content.key?("conditional_route_to") - content["conditional_route_to"].each do |route, answer| - if responses_for_page[question].present? && answer.include?(responses_for_page[question]) - return "case_log_#{route}_path" - end - end - end + next unless content.key?("conditional_route_to") - next unless content.key?("next_page") - - next_page = content["next_page"] - if next_page == "check_answers" - subsection = form.subsection_for_page(previous_page) - return "case_log_#{subsection}_check_answers_path" + content["conditional_route_to"].each do |route, answer| + if responses_for_page[question].present? && answer.include?(responses_for_page[question]) + return "case_log_#{route}_path" + end end - return "case_log_#{content[]}_path" end form.next_page_redirect_path(previous_page) diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 42a4f4f3b..01470d4e6 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -351,5 +351,11 @@ RSpec.describe "Test Features" do click_button("Save and continue") expect(page).to have_current_path("/case_logs/#{id}/conditional_question/check_answers") end + + it "can route to the default next page" do + visit("/case_logs/#{id}/conditional_question") + click_button("Save and continue") + expect(page).to have_current_path("/case_logs/#{id}/conditional_question/check_answers") + end end end