diff --git a/app/controllers/reminders_controller.rb b/app/controllers/reminders_controller.rb index 16386893c..4f1074a67 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 0c1e51a89..2d2b2ba07 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 6a2277b9b..a229fae76 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