Browse Source

push 1 failure

pull/49/head
magicmilo 4 years ago
parent
commit
c35877902f
  1. 8
      app/controllers/case_logs_controller.rb
  2. 5
      app/helpers/check_answers_helper.rb
  3. 7
      spec/features/case_log_spec.rb
  4. 6
      spec/fixtures/forms/test_form.json

8
app/controllers/case_logs_controller.rb

@ -98,14 +98,18 @@ private
end
def get_next_page_path(form, previous_page, responses_for_page = {})
# binding.pry
questions_for_page = form.questions_for_page(previous_page)
questions_for_page.each do |question, content|
next unless content.key?("conditional_route_to")
content["conditional_route_to"].each do |route, answer|
if responses_for_page[question] == answer
# binding.pry
if answer.include?(responses_for_page[question])
if route == "check_answers"
subsection = subsection_for_page(previous_page)
subsection = form.subsection_for_page(previous_page)
return "case_log_#{subsection}_check_answers_path"
end
return "case_log_#{route}_path"

5
app/helpers/check_answers_helper.rb

@ -18,12 +18,15 @@ module CheckAnswersHelper
questions_not_applicable << conditional_question_key
end
end
question.fetch("conditional_route_to", []).map do |conditional_page_key, condition|
#check_answers is not a real page
question.fetch("conditional_route_to", []).reject { |q| q == "check_answers" }.map do |conditional_page_key, condition|
if condition_not_met(case_log, question_key, question, condition)
questions_not_applicable += form.questions_for_page(conditional_page_key).keys
end
end
# binding.pry
questions_not_applicable.include?(question_key)
end
end

7
spec/features/case_log_spec.rb

@ -347,13 +347,10 @@ RSpec.describe "Test Features" do
it "can route based on page inclusion rules" do
visit("case_logs/#{id}/conditional_question")
choose("case-log-pregnancy-yes-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/case_logs/#{id}/conditional_question_yes_page")
visit("/case_logs/#{id}/conditional_question_yes_page")
choose("case-log-cbl-letting-yes-field", allow_label_click: true)
click_button("Save and continue")
expect(page).to have_current_path("/case_logs/conditional_question/check_answers")
expect(page).to have_current_path("/case_logs/#{id}/conditional_question/check_answers")
end
end
end

6
spec/fixtures/forms/test_form.json vendored

@ -267,8 +267,7 @@
"1": "No"
},
"conditional_route_to": {
"check_answers": "Yes",
"check_answers": "No"
"check_answers": ["Yes", "No"]
}
}
}
@ -282,6 +281,9 @@
"answer_options": {
"0": "Yes",
"1": "No"
},
"conditional_route_to": {
"conditional_question_no_second_page": ["Yes", "No"]
}
}
}

Loading…
Cancel
Save