diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index 927c13511..d764a4690 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -39,13 +39,12 @@ <% end %> <%= f.hidden_field :page, value: @page.id %> - <% next_page = @case_log.form.next_page(@page, @case_log, current_user) %> <% if !@page.id.include?("value_check") %> <%= f.govuk_submit "Save and continue" %> <% if @case_log.status == "in_progress" %> <%= govuk_link_to "Cancel", "/logs/#{@case_log.id}/setup/check-answers", secondary: true %> <% else %> - <%= govuk_link_to "Skip for now", "/logs/#{@case_log.id}/#{next_page.dasherize}", secondary: true %> + <%= govuk_link_to "Skip for now", send(@case_log.form.next_page_redirect_path(@page, @case_log, current_user), @case_log), secondary: true %> <% end %> <% end %> diff --git a/spec/features/form/form_navigation_spec.rb b/spec/features/form/form_navigation_spec.rb index 83dd82c72..1f7792075 100644 --- a/spec/features/form/form_navigation_spec.rb +++ b/spec/features/form/form_navigation_spec.rb @@ -73,6 +73,12 @@ RSpec.describe "Form Navigation" do expect(page).to have_current_path("/logs/#{empty_case_log.id}/person-1-age") end + it "routes to check answers when skipping on the last page in the form" do + visit("logs/#{empty_case_log.id}/propcode") + click_link(text: "Skip for now") + expect(page).to have_current_path("/logs/#{empty_case_log.id}/household-characteristics/check-answers") + end + describe "Back link directs correctly", js: true do it "go back to tasklist page from tenant code" do visit("/logs/#{id}")