Browse Source

CLDC-1277: no route matches bug (#615)

* don't display the save and go to the next incomplete section button if it errors 🤷‍♀️

* use 2022/23c fixture for in the test
pull/619/head
kosiakkatrina 3 years ago committed by baarkerlounger
parent
commit
88cffcc386
  1. 5
      app/views/form/check_answers.html.erb
  2. 5
      spec/fixtures/forms/2022_2023.json
  3. 19
      spec/requests/form_controller_spec.rb

5
app/views/form/check_answers.html.erb

@ -24,8 +24,9 @@
<%= form_with model: @case_log, method: "get" do |f| %>
<%= f.govuk_submit "Save and return to log" do %>
<% if @case_log.status == "in_progress" %>
<%= govuk_button_link_to "Save and go to next incomplete section", "/logs/#{@case_log.id}/#{@case_log.form.next_incomplete_section_redirect_path(subsection, @case_log)}", secondary: true %>
<% next_incomplete_section_redirect_path = @case_log.form.next_incomplete_section_redirect_path(subsection, @case_log) %>
<% if @case_log.status == "in_progress" && next_incomplete_section_redirect_path != "error" %>
<%= govuk_button_link_to "Save and go to next incomplete section", "/logs/#{@case_log.id}/#{next_incomplete_section_redirect_path}", secondary: true %>
<% end %>
<% end %>
<% end %>

5
spec/fixtures/forms/2022_2023.json vendored

@ -118,7 +118,12 @@
"derived": true,
"depends_on": [false]
}
},
"depends_on": [
{
"setup": "completed"
}
]
}
}
}

19
spec/requests/form_controller_spec.rb

@ -1,6 +1,7 @@
require "rails_helper"
RSpec.describe FormController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { FactoryBot.create(:user) }
let(:organisation) { user.organisation }
let(:other_organisation) { FactoryBot.create(:organisation) }
@ -36,6 +37,14 @@ RSpec.describe FormController, type: :request do
managing_organisation: organisation,
)
end
let(:case_log_2022) do
FactoryBot.create(
:case_log,
startdate: Time.zone.local(2022, 12, 1),
owning_organisation: organisation,
managing_organisation: organisation,
)
end
let(:headers) { { "Accept" => "text/html" } }
context "when a user is not signed in" do
@ -100,6 +109,16 @@ RSpec.describe FormController, type: :request do
expect(response).to have_http_status(:not_found)
end
end
context "when no other sections are enabled" do
before do
get "/logs/#{case_log_2022.id}/setup/check-answers", headers: headers, params: {}
end
it "does not show Save and go to next incomplete section button" do
expect(page).not_to have_content("Save and go to next incomplete section")
end
end
end
context "with a question in a section that isn't enabled yet" do

Loading…
Cancel
Save