Browse Source

Only set @interruption_page_id if http referrer is provided (#1697)

pull/1708/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
ede9beb385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/controllers/form_controller.rb
  2. 25
      spec/requests/form_controller_spec.rb

2
app/controllers/form_controller.rb

@ -46,7 +46,7 @@ class FormController < ApplicationController
end end
def show_page def show_page
if request.params["referrer"] == "interruption_screen" if request.params["referrer"] == "interruption_screen" && request.headers["HTTP_REFERER"].present?
@interruption_page_id = URI.parse(request.headers["HTTP_REFERER"]).path.split("/").last.underscore @interruption_page_id = URI.parse(request.headers["HTTP_REFERER"]).path.split("/").last.underscore
@interruption_page_referrer_type = referrer_from_query @interruption_page_referrer_type = referrer_from_query
end end

25
spec/requests/form_controller_spec.rb

@ -582,6 +582,31 @@ RSpec.describe FormController, type: :request do
end end
end end
end end
context "when requesting a soft validation page without a http referrer header" do
before do
get "/lettings-logs/#{lettings_log.id}/#{page_path}?referrer=interruption_screen", headers:
end
context "when the page is routed to" do
let(:page_path) { page_id.dasherize }
it "directs to the question page" do
expect(response.body).to include("What is the tenant’s age?")
expect(response.body).to include("Skip for now")
end
end
context "when the page is not routed to" do
let(:page_path) { "person-2-working-situation" }
it "redirects to the log page" do
follow_redirect!
expect(response.body).to include("Before you start")
expect(response.body).not_to include("Skip for now")
end
end
end
end end
context "with checkbox questions" do context "with checkbox questions" do

Loading…
Cancel
Save