From 02df8219702a486d6897994cfb81c67f4c8dc693 Mon Sep 17 00:00:00 2001 From: Kenneth Lee Date: Tue, 7 Jan 2025 18:37:21 +0000 Subject: [PATCH] CAPT-2104 Redirect to start page if no reminder in session --- app/controllers/reminders_controller.rb | 2 ++ app/forms/reminders/confirmation_form.rb | 2 +- spec/requests/reminders_spec.rb | 31 ++++++++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/controllers/reminders_controller.rb b/app/controllers/reminders_controller.rb index 16386893cc..4f1074a671 100644 --- a/app/controllers/reminders_controller.rb +++ b/app/controllers/reminders_controller.rb @@ -6,6 +6,8 @@ def show if @form.set_reminder_from_claim redirect_to reminder_path(journey: journey::ROUTING_NAME, slug: "confirmation") + elsif params[:slug] == "confirmation" && @form.reminder.nil? + redirect_to journey_session.journey_class.start_page_url else render view_file end diff --git a/app/forms/reminders/confirmation_form.rb b/app/forms/reminders/confirmation_form.rb index 0c1e51a89c..2d2b2ba07f 100644 --- a/app/forms/reminders/confirmation_form.rb +++ b/app/forms/reminders/confirmation_form.rb @@ -28,7 +28,7 @@ def set_reminder_from_claim private def itt_subject - journey_session.answers.eligible_itt_subject + defined?(journey_session.answers.eligible_itt_subject) ? journey_session.answers.eligible_itt_subject : nil end def itt_subject_for_submitted_claim diff --git a/spec/requests/reminders_spec.rb b/spec/requests/reminders_spec.rb index 6a2277b9ba..a229fae767 100644 --- a/spec/requests/reminders_spec.rb +++ b/spec/requests/reminders_spec.rb @@ -1,12 +1,12 @@ require "rails_helper" RSpec.describe "Claims" do - before do - create(:journey_configuration, :additional_payments) - start_claim("additional-payments") - end - describe "#create" do + before do + create(:journey_configuration, :additional_payments) + start_claim("additional-payments") + end + let(:submit_form) { put reminder_path(journey: "additional-payments", slug: "personal-details", params: form_params) } context "with full name and valid email address" do @@ -57,4 +57,25 @@ end end end + + # Rollbar error - confirmation page loaded without reminder that can be loaded from the session information + describe "#show" do + shared_examples "confirmation_page_no_reminder" do |journey| + before do + create(:journey_configuration, journey::ROUTING_NAME.underscore.to_sym) + end + + subject { get reminder_path(journey: journey::ROUTING_NAME.to_sym, slug: "confirmation") } + + it { is_expected.to redirect_to(journey.start_page_url) } + end + + describe "for FurtherEducationPayments journey" do + include_examples "confirmation_page_no_reminder", Journeys::FurtherEducationPayments + end + + describe "for AdditionalPaymentsForTeaching journey" do + include_examples "confirmation_page_no_reminder", Journeys::AdditionalPaymentsForTeaching + end + end end