Browse Source

make it route backwards on a no

pull/372/head
MadeTech Dushan 3 years ago committed by baarkerlounger
parent
commit
e9d094a498
  1. 15
      app/models/form.rb
  2. 21
      spec/features/form/validations_spec.rb

15
app/models/form.rb

@ -34,8 +34,19 @@ class Form
def next_page(page, case_log) def next_page(page, case_log)
page_ids = subsection_for_page(page).pages.map(&:id) page_ids = subsection_for_page(page).pages.map(&:id)
page_index = page_ids.index(page.id) if(page.id.include?("value_check"))
nxt_page = get_page(page_ids[page_index + 1]) question_id = page.id
if(case_log[page.id] == 1)
page_index = page_ids.index(page.id)
nxt_page = get_page(page_ids[page_index - 1])
else
page_index = page_ids.index(page.id)
nxt_page = get_page(page_ids[page_index + 1])
end
else
page_index = page_ids.index(page.id)
nxt_page = get_page(page_ids[page_index + 1])
end
return :check_answers if nxt_page.nil? return :check_answers if nxt_page.nil?
return nxt_page.id if nxt_page.routed_to?(case_log) return nxt_page.id if nxt_page.routed_to?(case_log)

21
spec/features/form/validations_spec.rb

@ -138,18 +138,15 @@ RSpec.describe "validations" do
expect(page).to have_current_path("/logs/#{case_log.id}/net-income-uc-proportion") expect(page).to have_current_path("/logs/#{case_log.id}/net-income-uc-proportion")
end end
# it "does not require confirming the value if the value is amended" do it "returns the user to the previous question if they do not confirm the value as correct on the interruption screen" do
# visit("/logs/#{case_log.id}/net-income") visit("/logs/#{case_log.id}/net-income")
# fill_in("case-log-earnings-field", with: income_over_soft_limit) fill_in("case-log-earnings-field", with: income_over_soft_limit)
# choose("case-log-incfreq-0-field", allow_label_click: true) choose("case-log-incfreq-0-field", allow_label_click: true)
# click_button("Save and continue") click_button("Save and continue")
# fill_in("case-log-earnings-field", with: income_under_soft_limit) choose("case-log-net-income-value-check-1-field", allow_label_click: true)
# click_button("Save and continue") click_button("Save and continue")
# expect(page).to have_current_path("/logs/#{case_log.id}/net-income-uc-proportion") expect(page).to have_current_path("/logs/#{case_log.id}/net-income")
# case_log.reload end
# expect(case_log.net_income_value_check).to be_nil
# end
# it "clears the confirmation question if the amount was amended and the page is returned to using the back button", js: true do # it "clears the confirmation question if the amount was amended and the page is returned to using the back button", js: true do
# visit("/logs/#{case_log.id}/net-income") # visit("/logs/#{case_log.id}/net-income")
# fill_in("case-log-earnings-field", with: income_over_soft_limit) # fill_in("case-log-earnings-field", with: income_over_soft_limit)

Loading…
Cancel
Save