Browse Source

Redirect to tasklist page if section or question is not enabled yet (#183)

pull/184/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
b9f60494d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/controllers/form_controller.rb
  2. 14
      spec/requests/form_controller_spec.rb

4
app/controllers/form_controller.rb

@ -35,7 +35,11 @@ class FormController < ApplicationController
if @case_log
@subsection = @case_log.form.subsection_for_page(page)
@page = @case_log.form.get_page(page.id)
if @page.routed_to?(@case_log) && @page.subsection.enabled?(@case_log)
render "form/page"
else
redirect_to case_log_path(@case_log)
end
else
render_not_found
end

14
spec/requests/form_controller_spec.rb

@ -76,6 +76,20 @@ RSpec.describe FormController, type: :request do
end
end
end
context "a question that in a section that isn't enabled yet" do
it "routes back to the tasklist page" do
get "/logs/#{case_log.id}/declaration", headers: headers, params: {}
expect(response).to redirect_to("/logs/#{case_log.id}")
end
end
context "a question that isn't enabled yet" do
it "routes back to the tasklist page" do
get "/logs/#{case_log.id}/conditional-question-no-second-page", headers: headers, params: {}
expect(response).to redirect_to("/logs/#{case_log.id}")
end
end
end
describe "Submit Form" do

Loading…
Cancel
Save