Feature/1887 Volunteer receives SMS notification when their account is reactivated by admin#3641
Merged
compwron merged 19 commits intorubyforgood:mainfrom Jun 15, 2022
Merged
Conversation
…them authorization or privilege)
…ent/stubbed with redirect)
compwron
reviewed
Jun 15, 2022
| send_sms_to(volunteers_phone_number, "Hello #{@volunteer.display_name}, \n \n Your CASA/Prince George’s County volunteer console account has been reactivated. You can login using the credentials you were already using. \n \n If you have any questions, please contact your most recent Case Supervisor for assistance. \n \n CASA/Prince George’s County") | ||
| redirect_to edit_volunteer_path(@volunteer), notice: "Volunteer reactivation alert sent" | ||
| else | ||
| redirect_to edit_volunteer_path(@volunteer), alert: "Volunteer reactivation alert failed" |
Collaborator
There was a problem hiding this comment.
Maybe add the failure notes from volunteer.errors.full_messages ?
compwron
reviewed
Jun 15, 2022
| end | ||
|
|
||
| def volunteers_phone_number | ||
| authorize @volunteer |
Collaborator
There was a problem hiding this comment.
you don't need to authorize twice
compwron
reviewed
Jun 15, 2022
|
|
||
| def send_sms_to(phone_number, body) | ||
| twilio = TwilioService.new(current_user.casa_org.twilio_api_key_sid, current_user.casa_org.twilio_api_key_secret, current_user.casa_org.twilio_account_sid) | ||
| req_params = {From: current_user.casa_org.twilio_phone_number, Body: body, To: phone_number} |
Collaborator
There was a problem hiding this comment.
lowercase is more normal than uppercase From
compwron
reviewed
Jun 15, 2022
| req_params = {From: current_user.casa_org.twilio_phone_number, Body: body, To: phone_number} | ||
| twilio_res = twilio.send_sms(req_params) | ||
|
|
||
| # Error handling for spec test purposes |
Collaborator
There was a problem hiding this comment.
It might be better to just leave twilio.send_sms(req_params) as the last line in the method so it is returned by default, and then assert on twilio_res.error_code directly in spec
compwron
reviewed
Jun 15, 2022
| resend_invitation_volunteer_path(user), | ||
| class: "btn btn-outline-danger" %> | ||
| <% end %> | ||
| <% if current_user.casa_admin? %> |
Collaborator
There was a problem hiding this comment.
linter might be sad here?
compwron
reviewed
Jun 15, 2022
| patch :activate | ||
| patch :deactivate | ||
| get :resend_invitation | ||
| get :send_reactivation_alert |
Collaborator
There was a problem hiding this comment.
Why is there a get here? Seems odd...
compwron
approved these changes
Jun 15, 2022
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What github issue is this PR for, if any?
Resolves #1887
What changed, and why?
Admins can send SMS messages to inform volunteers that their account was reactivated.
buttonand path'saction method endpointget and postmethods inroutes.rbsend_reactivation_alertto volunteerprivilegesinpolicies/volunteer_policy.rbAPIthrough newsend_sms_to(phone_number, body)method in volunteers controllerHow will this affect user permissions?
How is this tested? (please write tests!) 💖💪
Created a test to confirm
send_reactivation_alert_volunteer_pathredirects correctly. And added astub_requestto confirm the correspondingSMSis generated on said redirectScreenshots please :)
send-reactivation-alert.mov