Am exclude from court report issue 6429#6444
Merged
compwron merged 10 commits intorubyforgood:mainfrom Jul 7, 2025
Merged
Conversation
…alse and add enable and update its Controller/Form with its checkbox-related attribute
Contributor
Author
|
note: the change on |
compwron
reviewed
Jul 2, 2025
compwron
previously approved these changes
Jul 2, 2025
Collaborator
compwron
left a comment
There was a problem hiding this comment.
Seems good!
I wish we had a feature test change for this ticket also, maybe in a following PR...
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds the ability to mark contact topics so they are omitted from generated court reports by introducing a new boolean column, updating the query that builds report data, and exposing a checkbox in the admin UI.
- Added
exclude_from_court_reportboolean tocontact_topics(defaultfalse). - Filtered out excluded topics in
CaseCourtReportContext#court_topics. - Extended form, controller, and tests to support creating/updating the new flag.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| db/migrate/20250702142004_add_exclude_from_court_report_to_contact_topics.rb | Migration to add exclude_from_court_report column |
| db/schema.rb | Schema updated to include new column and version bump |
| app/models/case_court_report_context.rb | Added where(exclude_from_court_report: false) filter to court_topics |
| app/controllers/contact_topics_controller.rb | Permitted :exclude_from_court_report in strong params |
| app/views/contact_topics/_form.html.erb | Added a checkbox for exclude_from_court_report |
| spec/requests/contact_topics_spec.rb | Tests for setting exclude_from_court_report on create and update |
| spec/models/case_court_report_context_spec.rb | Expanded specs for court_topics shape, filtering by date, and exclusion behavior; contains some dead code to clean up |
| lib/tasks/no_contact_made_reminder.rb | Refactored safe navigation on case_contact_types.today? check |
| app/models/user.rb | Simplified parentheses in date comparison |
| app/models/contact_topic.rb | Updated schema comment to document new column |
Comments suppressed due to low confidence (2)
spec/models/case_court_report_context_spec.rb:197
- Remove commented-out test setup to improve clarity and avoid confusion; any necessary data creation should be clearly expressed in active code.
context "when given data" do
app/views/contact_topics/_form.html.erb:33
- [nitpick] Consider adding a view or system spec to verify that the
exclude_from_court_reportcheckbox is rendered and submits correctly.
<%= form.check_box :exclude_from_court_report, class: 'form-check-input' %>
compwron
reviewed
Jul 7, 2025
| expect(response).to redirect_to(edit_casa_org_path(casa_org)) | ||
| end | ||
|
|
||
| it "can change exclude_from_court_report" do |
compwron
reviewed
Jul 7, 2025
| expect(response).to redirect_to(edit_casa_org_path(casa_org)) | ||
| end | ||
|
|
||
| it "can set exclude_from_court_report attribute" do |
compwron
reviewed
Jul 7, 2025
| expect(court_topics["Question 1"][:answers].map { |a| a[:value] }).to match_array(["Answer 1", "Answer 3"]) | ||
| end | ||
|
|
||
| it "filters answers from topics set be excluded from court report" do |
compwron
approved these changes
Jul 7, 2025
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 #6429
What changed, and why?
.
🏛️ Backend & Database
Added the exclude_from_court_report boolean column to the contact_topics table. This column defaults to false so any existing ContactTopic will keep its current behavior.
Added a new where clause filtering
exclude_from_court_report: falseon CaseCourtReportContext on.court_topics, which is where the case/topics are filtered before being used on the report generation.🎨 Frontend
Contact Topic Form: A checkbox has been added to the _form.html.erb partial for contact topics. This allows administrators to easily toggle the "Exclude from Court Report?" setting for each topic.
🧪 Testing
Model Tests: Did some refactor on the ContactTopic related specs on case_court_report_context_spec.rb for clarity and now includes a specific test case to verify that topics marked for exclusion do not appear in the report data.
Request Tests: Added to contact_topics_spec.rb to ensure that the exclude_from_court_report attribute can be successfully set during both the creation and updating of a contact topic and the change is made to the record.
Screenshots please :)
New ContactTopic
Edit ContactTopic
A Court Report Generated
Report Generated after changing ContactTopic to exclude from court report.
After I manually checked "Exclude from Court Report" on the "Background information" ContactTopic

Feelings gif (optional)