-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
Email selected users when reimbursement requests are entered #5208
Changes from 7 commits
66f1fee
6a45698
b5c1563
97f0627
ff586a4
5dc4fbd
1d8db80
f35a840
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 |
---|---|---|
|
@@ -19,4 +19,13 @@ def weekly_digest(supervisor) | |
subject: "Weekly summary of volunteers' activities for the week of #{Date.today - 7.days}" | ||
) | ||
end | ||
|
||
def reimbursement_request_email(volunteer, supervisor) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be better to pass the case contact here. You still get volunteer and supervisor, but further down the road we could get more info into the email. Also see comment for |
||
@volunteer = volunteer | ||
@casa_organization = volunteer.casa_org | ||
@supervisor = supervisor | ||
if supervisor.receive_reimbursement_email | ||
mail(to: @supervisor.email, subject: "New reimbursement request from #{@volunteer.display_name}") | ||
end | ||
Comment on lines
+27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of an if conditional to make sure that receive_reimbursement_email is part of the supervisor parameter before sending mail to the supervisor email |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<meta itemprop="name" content="Volunteer Reimbursement Request Reminder" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> | ||
<style>/* Email styles need to be inline */</style> | ||
<table width="100%" cellpadding="0" cellspacing="0" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> | ||
<tr style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> | ||
<td class="content-block" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top"> | ||
Hello <%= @supervisor.display_name %>, | ||
</td> | ||
</tr> | ||
<tr style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"> | ||
<td class="content-block" style="font-family: Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top"> | ||
<%= @volunteer.display_name %> has submitted a reimbursement request, please follow up on the reimbursements page | ||
<%= link_to "using this link", reimbursements_url %>. | ||
</td> | ||
</tr> | ||
</table> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
RSpec.describe SupervisorMailerPreview do | ||
let!(:supervisor) { create(:supervisor) } | ||
let!(:volunteer) { create(:volunteer, casa_org: supervisor.casa_org, supervisor: supervisor) } | ||
|
||
describe "#account_setup" do | ||
context "When no ID is passed" do | ||
|
@@ -49,4 +50,20 @@ | |
xit { expect(email.to).to eq ["[email protected]"] } | ||
end | ||
end | ||
|
||
describe "#reimbursement_request_email" do | ||
context "When no ID is passed" do | ||
let(:preview) { described_class.new } | ||
let(:email) { preview.reimbursement_request_email } | ||
|
||
it { expect(email.to).to eq [supervisor.email] } | ||
end | ||
|
||
context "When passed ID is valid" do | ||
let(:preview) { described_class.new(volunteer_id: volunteer.id, supervisor_id: supervisor.id) } | ||
let(:email) { preview.reimbursement_request_email } | ||
|
||
it { expect(email.to).to eq [supervisor.email] } | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,4 +116,18 @@ | |
expect(email_body).to include("This invitation will expire on #{expiration_date} (two weeks).") | ||
end | ||
end | ||
|
||
describe ".reimbursement_request_email" do | ||
let(:supervisor) { create(:supervisor, receive_reimbursement_email: true) } | ||
let(:volunteer) { create(:volunteer) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make it explicit that the volunteer's supervisor is the supervisor created above? Might get flaky in the future if we don't. |
||
let(:casa_organization) { volunteer.casa_org } | ||
|
||
let(:mail) { SupervisorMailer.reimbursement_request_email(volunteer, supervisor) } | ||
|
||
it "sends email reminder" do | ||
expect(mail.subject).to eq("New reimbursement request from #{volunteer.display_name}") | ||
expect(mail.to).to eq([supervisor.email]) | ||
expect(mail.body.encoded).to match("#{volunteer.display_name} has submitted a reimbursement request") | ||
schoork marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
end | ||
end |
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.
If you switched this
!current_user.supervisor.blank?
to reference the case contact's supervisor, you could move the whole if statement into a method on case contact, unit test it, and ensure there are no problems in the future if we allow admins/someone else to submit these on behalf of volunteers. In that case, the current user's supervisor and case contact's supervisor might not be the same.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.
Thank you for the great feedback and changes done in this PR. I have gone through the commit and understood the fixes done in the code.