-
-
Notifications
You must be signed in to change notification settings - Fork 519
#6563 improve case contact workflow for supervisor and admin #6679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
f43ffed
8c6442a
4178a8f
7066812
9201608
fd1d775
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,8 @@ class CaseContactsController < ApplicationController | |
| before_action :set_case_contact, only: %i[edit destroy] | ||
| before_action :set_contact_types, only: %i[new edit create] | ||
| before_action :require_organization! | ||
| after_action :verify_authorized, except: %i[leave] | ||
| before_action :set_volunteer, only: %i[impersonate_and_edit] | ||
| after_action :verify_authorized, except: %i[leave impersonate_and_edit] | ||
|
|
||
| def index | ||
| load_case_contacts | ||
|
|
@@ -61,6 +62,12 @@ def leave | |
| redirect_back_to_referer(fallback_location: case_contacts_path) | ||
| end | ||
|
|
||
| def impersonate_and_edit | ||
| impersonate_user(@volunteer) | ||
|
|
||
| redirect_to casa_case_path(params[:casa_case_id]) | ||
| end | ||
|
Comment on lines
+65
to
+69
|
||
|
|
||
| private | ||
|
|
||
| def update_or_create_additional_expense(all_ae_params, cc) | ||
|
|
@@ -98,4 +105,8 @@ def build_draft_case_ids(params, casa_cases) | |
|
|
||
| [] | ||
| end | ||
|
|
||
| def set_volunteer | ||
| @volunteer = Volunteer.find(params[:creator_id]) | ||
| end | ||
|
Comment on lines
+109
to
+111
|
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,17 +73,16 @@ | |
| enable_pundit(view, admin) | ||
| allow(view).to receive(:current_user).and_return(admin) | ||
| end | ||
|
|
||
| context "occurred_at is before the last day of the month in the quarter that the case contact was created" do | ||
| let(:case_contact) { build_stubbed(:case_contact, creator: volunteer) } | ||
| let(:case_contact2) { build_stubbed(:case_contact, deleted_at: Time.current, creator: volunteer) } | ||
|
|
||
| it "shows edit button" do | ||
| it "shows view/edit button" do | ||
| assign :case_contact, case_contact | ||
| assign :casa_cases, [case_contact.casa_case] | ||
|
|
||
| render(partial: "case_contacts/case_contact", locals: {contact: case_contact}) | ||
| expect(rendered).to have_link(nil, href: "/case_contacts/#{case_contact.id}/edit") | ||
| expect(rendered).to have_link(nil, href: "/case_contacts/impersonate_and_edit?creator_id=#{case_contact.creator.id}") | ||
| end | ||
|
Comment on lines
+80
to
86
|
||
|
|
||
| it "shows make reminder button" do | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redirecting to
casa_case_path(params[:casa_case_id])after impersonation can fail because volunteers are only authorized to view cases they are actively assigned to (seeCasaCasePolicy#show?). If the case contact was authored by a volunteer who is no longer actively assigned, the impersonated session will be blocked from the case details page, defeating the workflow.Consider redirecting directly to the case contact edit flow (passing the case contact id) rather than the case details page, or otherwise ensuring the impersonated volunteer can access the target case.