Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle navigating past the country page after selecting an ineligible… #1769

Merged
merged 2 commits into from
Nov 14, 2023

Conversation

richardpattinson
Copy link
Contributor

… country

https://dfe-teacher-services.sentry.io/issues/3910860876/?project=6426061&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=14d&stream_index=2

We’ve got reports of this issue in Sentry, only happened 29 times and only seems to happen every few weeks, but we should investigate and fix the issue.

What happens if eligibility_check.status is something that_ isn’t _in paths.keys ?https://github.com/DFE-Digital/apply-for-qualified-teacher-status/blob/8cd32f1b31c[…]/app/controllers/concerns/enforce_eligibility_question_order.rb

Because there is one case where the region can be nil and the status will be something not in the list:

return :eligibility if country_eligibility_status == :ineligible

Reproducing the issue pre fix:

The steps are:

  • Start the eligibility checker

  • Choose an ineligible country (e.g. North Korea)

  • Ignore the ineligible result and go to the /eligibility/work-experience page

In that case we’ve got an eligibility check where region is nil , the status is :eligibility so it passes the order enforcement logic

The solution I've implemented is to check that the applicant is ineligible and redirect to the ineligible page if so. The applicant can still navigate to the country page.

@richardpattinson richardpattinson requested a review from a team as a code owner October 18, 2023 16:28
@richardpattinson richardpattinson force-pushed the handle_skipping_routes_in_eligibility_checker branch from e7fe7e7 to db3c2c6 Compare October 18, 2023 16:29
@syed87 syed87 added the deploy label Oct 24, 2023
@syed87 syed87 temporarily deployed to development October 24, 2023 08:55 — with GitHub Actions Inactive
@syed87 syed87 temporarily deployed to review October 24, 2023 09:15 — with GitHub Actions Inactive
@github-actions
Copy link

Copy link
Contributor

@syed87 syed87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@@ -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 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
eligibility_check&.status == :eligibility &&
eligibility_check&.status == :eligibility

The status of :eligibility includes both eligible and ineligible checks - if the check is eligible I don't think we want to redirect to the ineligible page.

Comment on lines 7 to 10
if request.path != eligibility_interface_countries_path &&
ineligible_application_without_skip_additional_questions
redirect_to eligibility_interface_ineligible_path
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right place to put this logic as this class shouldn't be concerned about the specifics of skipping additional questions, that's already handled by the status method so we don't want to be duplicating ourselves here (

unless skip_additional_questions?
return :degree if degree.nil?
return :teach_children if teach_children.nil?
if qualified_for_subject_required? && qualified_for_subject.nil?
return :qualified_for_subject
end
return :work_experience if work_experience.blank?
return :misconduct if free_of_sanctions.nil?
end
).

We also don't want to be just checking for this case when we're not on the countries path. Although at the moment this is only place we can get this sort of out-of-order issue, we should build this class in a generic way that allows it to work for any potential issues in the future.

The logic as written here also introduces a bug where users will get redirected to the ineligible page if they're eligible, skips additional questions and not on the countries path.

If there's an ineligible check we don't want to allow users to access
other pages of the eligibility checker.
I've renamed this to ResultController and simplified some of the logic.
@thomasleese thomasleese force-pushed the handle_skipping_routes_in_eligibility_checker branch from db3c2c6 to f817f1f Compare November 13, 2023 13:04
@thomasleese thomasleese disabled auto-merge November 13, 2023 13:13
@thomasleese thomasleese merged commit f34f31c into main Nov 14, 2023
12 checks passed
@thomasleese thomasleese deleted the handle_skipping_routes_in_eligibility_checker branch November 14, 2023 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants