-
Notifications
You must be signed in to change notification settings - Fork 4
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
Change condition model to delete secondary skip routes when skip route is deleted #686
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lfdebrux
added a commit
to alphagov/forms-admin
that referenced
this pull request
Feb 6, 2025
Currently (when branching is enabled) deleting a skip route for a question that has a secondary skip route puts the form in a state where there is a route with an error that can’t be deleted. We do want users to be able to delete individual routes for a question. So we’ve agreed that we will delete the secondary skip for a question when deleting any other routes for that question. And we’ll let the user know before the delete a route, with a warning. This commit adds the warning; note that the deletion will take place in forms-api, see alphagov/forms-api#686. To enable this we add a method `#has_secondary_skip?` to the DeleteConfirmationInput object... I'm not sure if this is the best place for this, but it'll do for now.
9961ffd
to
6694009
Compare
lfdebrux
added a commit
to alphagov/forms-admin
that referenced
this pull request
Feb 6, 2025
Currently (when branching is enabled) deleting a skip route for a question that has a secondary skip route puts the form in a state where there is a route with an error that can’t be deleted. We do want users to be able to delete individual routes for a question. So we’ve agreed that we will delete the secondary skip for a question when deleting any other routes for that question. And we’ll let the user know before the delete a route, with a warning. This commit adds the warning; note that the deletion will take place in forms-api, see alphagov/forms-api#686. To enable this we add a method `#has_secondary_skip?` to the DeleteConfirmationInput object... I'm not sure if this is the best place for this, but it'll do for now.
lfdebrux
added a commit
to alphagov/forms-admin
that referenced
this pull request
Feb 7, 2025
Currently (when branching is enabled) deleting a skip route for a question that has a secondary skip route puts the form in a state where there is a route with an error that can’t be deleted. We do want users to be able to delete individual routes for a question. So we’ve agreed that we will delete the secondary skip for a question when deleting any other routes for that question. And we’ll let the user know before the delete a route, with a warning. This commit adds the warning; note that the deletion will take place in forms-api, see alphagov/forms-api#686. To enable this we add a method `#has_secondary_skip?` to the DeleteConfirmationInput object... I'm not sure if this is the best place for this, but it'll do for now.
jamie-o-wilkinson
approved these changes
Feb 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have talked this through with @lfdebrux, all looks good to me 👍
lfdebrux
added a commit
to alphagov/forms-admin
that referenced
this pull request
Feb 10, 2025
Currently (when branching is enabled) deleting a skip route for a question that has a secondary skip route puts the form in a state where there is a route with an error that can’t be deleted. We do want users to be able to delete individual routes for a question. So we’ve agreed that we will delete the secondary skip for a question when deleting any other routes for that question. And we’ll let the user know before the delete a route, with a warning. This commit adds the warning; note that the deletion will take place in forms-api, see alphagov/forms-api#686. To enable this we add a method `#has_secondary_skip?` to the DeleteConfirmationInput object... I'm not sure if this is the best place for this, but it'll do for now.
…e is deleted Currently deleting a skip route for a question that has a secondary skip route puts the form in a state where there is an invalid route that can’t be deleted. We've decided to fix this by making it so that deleting a route for a page also deletes any secondary skip routes for that page. Because routes and associations between conditions are directly expressed in our model, we need to jump through some hoops to make this work. This commit adds a before_destroy callback to take care of things.
6694009
to
e4b9f09
Compare
|
lfdebrux
added a commit
to alphagov/forms-admin
that referenced
this pull request
Feb 13, 2025
We've found that in production the "delete all routes" journey has stopped working properly; after the user confirms that they want to delete all routes for a question, they see an error page rather than being redirected to the "add and edit questions" page as expected. Debugging locally revealed this is an unintended side-effect of an unrelated change in forms-api, in PR alphagov/forms-api#686, which changes the conditions model to delete secondary skip routes when a skip route is deleted. Because the process to delete all routes deletes the primary condition before the secondary skip, when it comes to delete the secondary skip that no longer exists, and the API responds with a 404. This 404 is then parlayed by ActiveResource into a ResourceNotFound exception, which then bubbles up to the Rails middleware, and is treated as a record not found error, and Rails renders a 404 error page. This commit adds a test that simulates this interaction, so we can make some changes in our system to handle the scenario better.
lfdebrux
added a commit
to alphagov/forms-admin
that referenced
this pull request
Feb 13, 2025
We've found that in production the "delete all routes" journey has stopped working properly; after the user confirms that they want to delete all routes for a question, they see an error page rather than being redirected to the "add and edit questions" page as expected. Debugging locally revealed this is an unintended side-effect of an unrelated change in forms-api, in PR alphagov/forms-api#686, which changes the conditions model to delete secondary skip routes when a skip route is deleted. Because the process to delete all routes deletes the primary condition before the secondary skip, when it comes to delete the secondary skip that no longer exists, and the API responds with a 404. This 404 is then parlayed by ActiveResource into a ResourceNotFound exception, which then bubbles up to the Rails middleware, and is treated as a record not found error, and Rails renders a 404 error page. This commit adds a test that simulates this interaction, so we can make some changes in our system to handle the scenario better.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this pull request solve?
Trello card: https://trello.com/c/iMnMgYPr/2106-deleting-a-route-should-delete-the-secondary-skip-route-for-the-same-question
Currently deleting a skip route for a question that has a secondary skip route puts the form in a state where there is an invalid route that can’t be deleted.
We've decided to fix this by making it so that deleting a route for a page also deletes any secondary skip routes for that page.
Because routes and associations between conditions are directly expressed in our model, we need to jump through some hoops to make this work. This commit adds a before_destroy callback to take care of things.
Things to consider when reviewing