Display error message for unauthorized court date visit attempt - #6460
Merged
compwron merged 5 commits intoJul 23, 2025
Merged
Conversation
kanishk333gupta
requested review from
FireLemons,
compwron and
elasticspoon
as code owners
July 23, 2025 14:02
compwron
previously approved these changes
Jul 23, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR replaces a 404 error with a more user-friendly unauthorized access message when users attempt to access court dates they don't have permission to view. The change improves the user experience by providing clearer feedback about authorization issues.
- Added error handling in the
set_casa_casemethod to catch unauthorized access attempts - Updated the response to redirect users to the casa cases page with an informative flash message
- Modified tests to verify the new redirect behavior instead of expecting a 404 response
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/controllers/court_dates_controller.rb | Added rescue block to handle unauthorized access with redirect and flash message |
| spec/requests/court_dates_spec.rb | Updated test expectations to verify redirect behavior and flash message |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
Thanks @compwron for improving silly mistakes. I did my changes in local and pasted it in codespace, which was not working fine right now, for adding PR. So missed these completely. |
This file contains hidden or 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
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 github issue is this PR for, if any?
Resolves #6457
What changed, and why?
Showing unauthorized message instead of 404 error. We were getting this error when user not authorized to view a court date either from an organization not containing the court date's parent casa case or a volunteer not assigned to the court date's parent casa case.
How is this tested? (please write rspec and jest tests!) 💖💪
Updated
spec/requests/court_dates_spec.rb.Screenshots
For fix, I have used similar pattern for errors as how it's used in
app/controllers/casa_cases_controller.rb#set_casa_case.