-
-
Notifications
You must be signed in to change notification settings - Fork 529
feature #3616 - "Set your account" password link in SMS activation messages #3700
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5e537dd
add to supervisor request specs to assert for short io api calls
xihai01 b6e5198
create controller tests for handle_short_url function
xihai01 afa1448
implement a protected function in application controller to handle sh…
xihai01 ac4061d
refactor config/init/constants.rb into three separate files under app…
xihai01 45f38ff
add helper spec for sms body text
xihai01 ccddcef
refactor sms body helper function to dynamically create body message …
xihai01 5f5af67
add functionality to supervisor controller create action to send shor…
xihai01 63c7729
add functionality to volunteer/admin controller create actions to sen…
xihai01 0328369
fix typo in assertion
xihai01 1f93e58
run test suite and lint files
xihai01 7ad81d6
add helper files to deny list (no need for spec tests)
xihai01 e84bbc3
refactor sms body helper because of cognitive complexity
xihai01 bdb2973
fix typo in sustem/other_duties assertion
xihai01 02ca4ab
refactor controllers to reduce duplication
xihai01 374191c
lint files
xihai01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,17 +30,30 @@ def after_sign_out_path_for(resource_or_scope) | |
|
|
||
| protected | ||
|
|
||
| def handle_short_url(url_list) | ||
| hash_of_short_urls = {} | ||
| url_list.each_with_index { |val, index| | ||
| # call short io service to shorten url | ||
|
Collaborator
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 comment |
||
| # create an entry in hash if api is success | ||
| short_io_service = ShortUrlService.new | ||
| response = short_io_service.create_short_url(val) | ||
| short_url = short_io_service.short_url | ||
| hash_of_short_urls[index] = response.code == 201 || response.code == 200 ? short_url : nil | ||
| } | ||
| hash_of_short_urls | ||
| end | ||
|
|
||
| # volunteer/supervisor/casa_admin controller uses to send SMS | ||
| # returns appropriate flash notice for SMS | ||
| def deliver_sms_to(phone_number, body_msg) | ||
| if phone_number.blank? | ||
| def deliver_sms_to(resource, body_msg) | ||
| if resource.phone_number.blank? | ||
| return "blank" | ||
| end | ||
| acc_sid = current_user.casa_org.twilio_account_sid | ||
| api_key = current_user.casa_org.twilio_api_key_sid | ||
| api_secret = current_user.casa_org.twilio_api_key_secret | ||
| body = body_msg | ||
| to = phone_number | ||
| to = resource.phone_number | ||
| from = current_user.casa_org.twilio_phone_number | ||
|
|
||
| twilio = TwilioService.new(api_key, api_secret, acc_sid) | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module ApiBaseHelper | ||
| SHORT_IO = "https://api.short.io/" | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module RequestHeaderHelper | ||
| ACCEPT_JSON = {"Accept" => "application/json"} | ||
| CONTENT_TYPE_JSON = {"Content-Type" => "application/json"} | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| module SmsBodyHelper | ||
| def account_activation_msg(resource = "primorgens", hash_of_links = {}) | ||
| password_link = hash_of_links[0] | ||
| edit_link = hash_of_links[1] | ||
| first_msg = "A CASA #{resource} account was created for you." | ||
| second_msg = "First, set your password here #{hash_of_links[0]}." | ||
| third_msg = "Then visit #{hash_of_links[1]} to change your text message settings." | ||
| # default msg | ||
| body_msg = first_msg + " " + "Please check your email to set up your password. Go to profile edit page to change SMS settings." | ||
|
|
||
| if password_link && edit_link | ||
| body_msg = first_msg + " " + second_msg + " " + third_msg | ||
| elsif password_link.nil? && edit_link | ||
| body_msg = first_msg + " " + "Please check your email to set up your password." + " " + third_msg | ||
| elsif hash_of_links[0] && hash_of_links[1].nil? | ||
| body_msg = first_msg + " " + second_msg + " " + "Go to profile edit page to change SMS settings." | ||
| end | ||
| body_msg | ||
| end | ||
| end |
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
This file was deleted.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| require "rails_helper" | ||
|
|
||
| RSpec.describe SmsBodyHelper do | ||
| describe "#account_activation_msg" do | ||
| it "correct short links provided" do | ||
| expected_response = account_activation_msg("primogems", {0 => "www.pasta.com", 1 => "www.yogurt.com"}) | ||
| expect(expected_response).to include("First, set your password here www.pasta.com. Then visit www.yogurt.com to change your text message settings.") | ||
| end | ||
|
|
||
| it "incorrect short links provided" do | ||
| expected_response = account_activation_msg("primogems", {0 => nil, 1 => nil}) | ||
| expect(expected_response).to include("Please check your email to set up your password. Go to profile edit page to change SMS settings.") | ||
| end | ||
|
|
||
| it "set up password link invalid" do | ||
| expected_response = account_activation_msg("primogems", {0 => nil, 1 => "www.carfax.com"}) | ||
| expect(expected_response).to include("Please check your email to set up your password. Then visit www.carfax.com to change your text message settings.") | ||
| end | ||
|
|
||
| it "link to users/edit invalid" do | ||
| expected_response = account_activation_msg("primogems", {0 => "www.yummy.com", 1 => nil}) | ||
| expect(expected_response).to include("First, set your password here www.yummy.com. Go to profile edit page to change SMS settings.") | ||
| end | ||
| end | ||
| end |
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
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
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
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
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.
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.
Please write tests for code instead of ignoring them
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.
got it