diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 3d539f4a9..fdd9dfa0e 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -133,10 +133,7 @@ private next_page = @log.form.next_page(@page, @log, current_user) previous_page = @log.form.previous_page(page_ids, page_index, @log, current_user) if next_page.to_s.include?("value_check") || next_page == previous_page - binding.pry - "lettings_log_void_or_renewal_date_path" - "#{@log.class.name.underscore}_#{next_page}" - return "/logs/#{@log.id}/#{next_page.dasherize}?referrer=check_answers" + return send("#{@log.class.name.underscore}_#{next_page}_path", @log, { referrer: "check_answers" }) else return send("#{@log.model_name.param_key}_#{@log.form.subsection_for_page(@page).id}_check_answers_path", @log) end diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index ec85104c5..91a3afc94 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -32,7 +32,7 @@ <%= f.govuk_submit "Save and return to log" do %> <% next_incomplete_section_redirect_path = @log.form.next_incomplete_section_redirect_path(subsection, @log) %> <% if @log.status == "in_progress" && next_incomplete_section_redirect_path != "error" %> - <%= govuk_button_link_to "Save and go to next incomplete section", "/logs/#{@log.id}/#{next_incomplete_section_redirect_path}", secondary: true %> + <%= govuk_button_link_to "Save and go to next incomplete section", send("#{@log.class.name.underscore}_#{next_incomplete_section_redirect_path.underscore.gsub("/","_")}_path", @log) , secondary: true %> <% end %> <% end %> <% end %> diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index 542f5fd51..b122274f4 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -45,7 +45,7 @@ <%= govuk_link_to "Skip for now", send(@log.form.next_page_redirect_path(@page, @log, current_user), @log) %> <% else %> <%= f.govuk_submit "Save changes" %> - <%= govuk_link_to "Cancel", "/logs/#{@log.id}/setup/check-answers" %> + <%= govuk_link_to "Cancel", send("#{@log.class.name.underscore}_#{@page.subsection.id}_check_answers_path", @log) %> <% end %> <% end %> diff --git a/spec/features/form/form_navigation_spec.rb b/spec/features/form/form_navigation_spec.rb index abc4e4fdf..fc19be3ce 100644 --- a/spec/features/form/form_navigation_spec.rb +++ b/spec/features/form/form_navigation_spec.rb @@ -115,7 +115,7 @@ RSpec.describe "Form Navigation" do it "a question page has a link allowing you to cancel your input and return to the check answers page" do visit("logs/#{id}/tenant-code-test?referrer=check_answers") click_link(text: "Cancel") - expect(page).to have_current_path("/logs/#{id}/setup/check-answers") + expect(page).to have_current_path("/logs/#{id}/household-characteristics/check-answers") end context "when clicking save and continue on a mandatory question with no input" do