Skip to content

Commit

Permalink
Merge pull request #3314 from DFE-Digital/LUPEYALPHA-1155/only-set-vi…
Browse files Browse the repository at this point in the history
…sited-slugs-on-success

LUPEYALPHA-1155 / Only update visited slugs if form submission succeeded
  • Loading branch information
rjlynch authored Oct 17, 2024
2 parents b47a166 + 6e7a8cd commit 65195a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class ClaimsController < BasePublicController
skip_before_action :send_unstarted_claimants_to_the_start, only: [:new, :create]
before_action :initialize_session_slug_history
before_action :check_page_is_in_sequence, only: [:show, :update]
before_action :update_session_with_current_slug, only: [:update]
before_action :set_backlink_path, only: [:show, :update]
before_action :check_claim_not_in_progress, only: [:new]
before_action :clear_claim_session, only: [:new], unless: -> { journey.start_with_magic_link? }
before_action :prepend_view_path_for_journey
before_action :persist_claim, only: [:new, :create]
before_action :handle_magic_link, only: [:new], if: -> { journey.start_with_magic_link? }
after_action :update_session_with_current_slug, only: [:update]

include AuthorisedSlugs
include FormSubmittable
Expand Down Expand Up @@ -90,7 +90,11 @@ def initialize_session_slug_history
end

def update_session_with_current_slug
session[:slugs] << params[:slug] unless Journeys::PageSequence::DEAD_END_SLUGS.include?(params[:slug])
if @form.nil? || @form.valid?
session[:slugs] << params[:slug] unless Journeys::PageSequence::DEAD_END_SLUGS.include?(params[:slug])
else
# Don't count form as visited if it's invalid
end
end

def check_claim_not_in_progress
Expand Down

0 comments on commit 65195a5

Please sign in to comment.