Skip to content

Am exclude from court report issue 6429#6444

Merged
compwron merged 10 commits intorubyforgood:mainfrom
amuta:am-exclude-from-court-report-issue-6429
Jul 7, 2025
Merged

Am exclude from court report issue 6429#6444
compwron merged 10 commits intorubyforgood:mainfrom
amuta:am-exclude-from-court-report-issue-6429

Conversation

@amuta
Copy link
Contributor

@amuta amuta commented Jul 2, 2025

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: false on 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

Screenshot from 2025-07-02 13-15-35

Edit ContactTopic

Screenshot from 2025-07-02 13-15-55

A Court Report Generated

Screenshot from 2025-07-02 13-17-39

Report Generated after changing ContactTopic to exclude from court report.

After I manually checked "Exclude from Court Report" on the "Background information" ContactTopic
Screenshot from 2025-07-02 13-18-48

Feelings gif (optional)

Glad to Help!

@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 erb labels Jul 2, 2025
@amuta amuta marked this pull request as ready for review July 2, 2025 16:35
@amuta
Copy link
Contributor Author

amuta commented Jul 2, 2025

note: the change on models/user.rb was generated by the linter bin/lint.

@compwron compwron requested a review from Copilot July 2, 2025 19:21

This comment was marked as outdated.

compwron
compwron previously approved these changes Jul 2, 2025
Copy link
Collaborator

@compwron compwron left a comment

Choose a reason for hiding this comment

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

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>
compwron and others added 2 commits July 2, 2025 12:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@amuta amuta requested a review from compwron July 2, 2025 19:52
@compwron compwron requested a review from Copilot July 3, 2025 19:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_report boolean to contact_topics (default false).
  • 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_report checkbox is rendered and submits correctly.
      <%= form.check_box :exclude_from_court_report, class: 'form-check-input' %>

expect(response).to redirect_to(edit_casa_org_path(casa_org))
end

it "can change exclude_from_court_report" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

yay tests :)

expect(response).to redirect_to(edit_casa_org_path(casa_org))
end

it "can set exclude_from_court_report attribute" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

yay tests :)

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

yay tests :)

@compwron compwron merged commit 55aeb56 into rubyforgood:main Jul 7, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

erb ruby Pull requests that update Ruby code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude Section from Court Report (Checkbox)

3 participants