Skip to content

Commit

Permalink
Handle navigating past the country page after selecting an ineligible…
Browse files Browse the repository at this point in the history
… country
  • Loading branch information
richardpattinson committed Oct 18, 2023
1 parent dcafb2b commit db3c2c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module EnforceEligibilityQuestionOrder
included { before_action :redirect_by_status }

def redirect_by_status
if request.path != eligibility_interface_countries_path &&
ineligible_application_without_skip_additional_questions
redirect_to eligibility_interface_ineligible_path
end
return if current_page_is_allowed?

expected_path = paths[eligibility_check.status]
Expand All @@ -18,6 +22,11 @@ def current_page_is_allowed?
current_position && order && current_position <= order
end

def ineligible_application_without_skip_additional_questions
eligibility_check&.status == :eligibility &&
!eligibility_check.skip_additional_questions?
end

def paths
{
country: eligibility_interface_countries_path,
Expand Down
14 changes: 14 additions & 0 deletions spec/system/eligibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,20 @@
then_i_see_the(:eligibility_ineligible_page)
end

it "ineligible path when filtering by country, not qualified in relevant subject" do
when_i_visit_the(:eligibility_start_page)
then_i_see_the(:eligibility_start_page)

when_i_press_start_now
then_i_see_the(:eligibility_country_page)

when_i_select_an_ineligible_country
then_i_see_the(:eligibility_ineligible_page)

when_i_visit_the(:eligibility_qualification_page)
then_i_see_the(:eligibility_ineligible_page)
end

private

def then_access_is_denied
Expand Down

0 comments on commit db3c2c6

Please sign in to comment.