Browse Source

Changed logic to check last page visited was check answers

pull/708/head
Ted 3 years ago
parent
commit
c38b4e1c8a
  1. 4
      app/views/form/page.html.erb
  2. 2
      spec/features/form/form_navigation_spec.rb

4
app/views/form/page.html.erb

@ -5,7 +5,6 @@
<% end %> <% end %>
<div data-controller="govukfrontend"></div> <div data-controller="govukfrontend"></div>
<%= form_with model: @case_log, url: form_case_log_path(@case_log), method: "post", local: true do |f| %> <%= form_with model: @case_log, url: form_case_log_path(@case_log), method: "post", local: true do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-<%= @page.questions[0].type == "interruption_screen" ? "full-from-desktop" : "two-thirds-from-desktop" %>"> <div class="govuk-grid-column-<%= @page.questions[0].type == "interruption_screen" ? "full-from-desktop" : "two-thirds-from-desktop" %>">
@ -39,9 +38,10 @@
<% end %> <% end %>
<%= f.hidden_field :page, value: @page.id %> <%= f.hidden_field :page, value: @page.id %>
<% if !@page.id.include?("value_check") %> <% if !@page.id.include?("value_check") %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>
<% if @case_log.status == "in_progress" %> <% if request.query_parameters["referrer"] == "check_answers" %>
<%= govuk_link_to "Cancel", "/logs/#{@case_log.id}/setup/check-answers", secondary: true %> <%= govuk_link_to "Cancel", "/logs/#{@case_log.id}/setup/check-answers", secondary: true %>
<% else %> <% else %>
<%= govuk_link_to "Skip for now", send(@case_log.form.next_page_redirect_path(@page, @case_log, current_user), @case_log), 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 %>

2
spec/features/form/form_navigation_spec.rb

@ -62,7 +62,7 @@ RSpec.describe "Form Navigation" do
end end
it "a question page has a link allowing you to cancel your input and return to the check answers page" 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") visit("logs/#{id}/tenant-code-test?referrer=check_answers")
click_link(text: "Cancel") click_link(text: "Cancel")
expect(page).to have_current_path("/logs/#{id}/setup/check-answers") expect(page).to have_current_path("/logs/#{id}/setup/check-answers")
end end

Loading…
Cancel
Save