Skip to content

[6199] BUG: case contacts showing for unassigned volunteers#6278

Merged
compwron merged 4 commits intomainfrom
6199-bug-case-contacts-showing-for-unassigned-volunteers
Mar 31, 2025
Merged

[6199] BUG: case contacts showing for unassigned volunteers#6278
compwron merged 4 commits intomainfrom
6199-bug-case-contacts-showing-for-unassigned-volunteers

Conversation

@DianaLiao
Copy link
Copy Markdown
Collaborator

@DianaLiao DianaLiao commented Mar 21, 2025

What github issue is this PR for, if any?

Resolves #6199

What changed, and why?

Added an filtering step in the case_contacts controller for the index if a volunteer is logged in to only pass on case contacts for assigned cases to the view.
Volunteers should not be seeing case contacts for cases no longer assigned to them.

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

A test was added where a volunteer is logged in and is the creator of two case contacts, one for an assigned case (with a duration of 180 minutes) and one for a case that is not assigned to them (with factory default duration of 60 min). The test checks the page for the presence of "60 minutes" and omission of "3 hours".

Screenshots please :)

URL when logged in as a volunteer: http://127.0.0.1:3000/case_contacts

Before:
Screenshot 2025-03-21 at 1 32 32 PM

Case contacts included without a Case No heading (meaning it's been unassigned.)

After:
Screenshot 2025-03-21 at 1 32 58 PM

Orphaned case contacts no longer display below assigned case case contacts.

Feelings gif (optional)

I don't know what's happening

@DianaLiao DianaLiao marked this pull request as draft March 21, 2025 17:25
@github-actions github-actions bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 labels Mar 21, 2025
Copy link
Copy Markdown
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.

good test

@DianaLiao DianaLiao changed the title WIP [6199] BUG: case contacts showing for unassigned volunteers [6199] BUG: case contacts showing for unassigned volunteers Mar 25, 2025

@pagy, @filtered_case_contacts = pagy(@filterrific.find)
case_contacts = CaseContact.case_hash_from_cases(@filtered_case_contacts)
case_contacts = case_contacts.select { |k, _v| current_user.casa_cases.pluck(:id).include?(k) } if current_user.volunteer?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ideally this type of logic would be in a pundit policy file but we are very spotty with that in general, so dont worry about it in this pr

@compwron
Copy link
Copy Markdown
Collaborator

Rebasing should fix most of the failures - I will try it and merge if so.

@compwron compwron force-pushed the 6199-bug-case-contacts-showing-for-unassigned-volunteers branch from 9a87510 to b790b77 Compare March 31, 2025 03:54
@compwron compwron marked this pull request as ready for review March 31, 2025 04:08
@compwron compwron enabled auto-merge March 31, 2025 04:08
@compwron compwron merged commit 75ba45e into main Mar 31, 2025
12 checks passed
@compwron compwron deleted the 6199-bug-case-contacts-showing-for-unassigned-volunteers branch March 31, 2025 04:37
@bcastillo32
Copy link
Copy Markdown
Collaborator

@compwron @DianaLiao

When I log a case contact, it is not showing for me unless I am on page 3 or 5 (something is wrong with the pagination I guess). Do you have any idea why this could be? I can create a bug ticket. This is happening in QA.
image
image
image

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: logged case contacts showing for unassigned volunteer in "All Case Contacts"

3 participants