Skip to content

#7241 Fix reassigned cases listed as "Not Assigned" when assigning a case - #7358

Open
Anandb71 wants to merge 1 commit into
rubyforgood:mainfrom
Anandb71:7241-reassigned-cases-not-assigned
Open

Anandb71 wants to merge 1 commit into
rubyforgood:mainfrom
Anandb71:7241-reassigned-cases-not-assigned

Conversation

@Anandb71

Copy link
Copy Markdown

What github issue is this PR for, if any?

Resolves #7241

What changed, and why?

On the Edit Volunteer page, the "Assign a new case" dropdown listed a reassigned case under "Not Assigned" (with the currently assigned volunteer's name next to the case number) and again under "Assigned".

CasaCase.not_assigned left joined case_assignments and kept rows where the assignment was missing or inactive. That condition is evaluated per assignment row, so a case with one inactive assignment (the previous volunteer) and one active assignment (the current volunteer) still matched through the inactive row.

The scope now returns cases in the org that have no active assignment, using a subquery on active case assignments (where.not(id: CaseAssignment.active.select(:casa_case_id))). Cases that were never assigned, or whose assignments are all inactive, are still returned, so a volunteer can still be re-assigned to a case they were unassigned from. not_assigned is only used by UiHelper#grouped_options_for_assigning_case.

How is this tested? (please write rspec and jest tests!) 💖💪

  • Model spec (spec/models/casa_case_spec.rb): a case with an inactive assignment and an active one is not returned by .not_assigned.
  • System spec (spec/system/volunteers/edit_spec.rb, rack_test): on the Edit Volunteer page, a reassigned case is listed under "Assigned" and not under "Not Assigned".
  • Both new specs fail on main (the system spec finds "REASSIGNED - User 4" under "Not Assigned") and pass with this change.
  • Also ran spec/models/casa_case_spec.rb, spec/models/case_assignment_spec.rb, spec/helpers/ui_helper_spec.rb, spec/requests/case_assignments_spec.rb and spec/views/volunteers (118 examples, 0 failures), plus the non-JS examples in spec/system/volunteers/edit_spec.rb (34 examples, 0 failures).
  • bundle exec standardrb on the changed files: no offenses.

Screenshots please :)

The change is in the not_assigned scope; the system spec above checks the dropdown groups directly. Happy to add screenshots if that would help review.

On the volunteer edit page, the "Assign a new case" dropdown groups
cases into "Not Assigned" and "Assigned". A case that had been
reassigned (an inactive assignment for the previous volunteer plus an
active one for the current volunteer) showed up in both groups, and
under "Not Assigned" its badge named the volunteer it is assigned to.

CasaCase.not_assigned left joined case_assignments and kept rows where
the assignment was missing or inactive. That condition is evaluated per
assignment row, so a single inactive assignment was enough to return
the case even though another assignment for it was still active.

Return cases that have no active assignment instead, using a subquery
on active case assignments. Cases that were never assigned, or whose
assignments are all inactive, are still returned as before.
@github-actions github-actions Bot added 🧪 Tests Tests ruby Touches Ruby code labels Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Reassigned cases are listed under "Not Assigned" in the Assign a new case dropdown

1 participant