Browse Source

remove unused code from get next page path

pull/49/head
Kat 4 years ago
parent
commit
663f8cff2a
  1. 19
      app/controllers/case_logs_controller.rb
  2. 6
      spec/features/case_log_spec.rb

19
app/controllers/case_logs_controller.rb

@ -132,22 +132,13 @@ private
def get_next_page_path(form, previous_page, responses_for_page = {}) def get_next_page_path(form, previous_page, responses_for_page = {})
questions_for_page = form.questions_for_page(previous_page) questions_for_page = form.questions_for_page(previous_page)
questions_for_page.each do |question, content| questions_for_page.each do |question, content|
if content.key?("conditional_route_to") next unless 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?("next_page") content["conditional_route_to"].each do |route, answer|
if responses_for_page[question].present? && answer.include?(responses_for_page[question])
next_page = content["next_page"] return "case_log_#{route}_path"
if next_page == "check_answers" end
subsection = form.subsection_for_page(previous_page)
return "case_log_#{subsection}_check_answers_path"
end end
return "case_log_#{content[]}_path"
end end
form.next_page_redirect_path(previous_page) form.next_page_redirect_path(previous_page)

6
spec/features/case_log_spec.rb

@ -351,5 +351,11 @@ RSpec.describe "Test Features" do
click_button("Save and continue") click_button("Save and continue")
expect(page).to have_current_path("/case_logs/#{id}/conditional_question/check_answers") expect(page).to have_current_path("/case_logs/#{id}/conditional_question/check_answers")
end 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
end end

Loading…
Cancel
Save