-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sends recover email to main email address & fallback
Issue on production with user not recieving email on their main email address, only getting sent to the fallback email. Decided to just send one email with both address (doubt why, should just be the email used in recovery).
- Loading branch information
1 parent
aea5c09
commit 6b5ba5c
Showing
2 changed files
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -65,9 +65,7 @@ def account_recovery_instructions user_id | |
@user = User.find(user_id) | ||
emails = [@user.email_string, @user.email_fallback].reject(&:blank?) | ||
|
||
emails.each do |email| | ||
mail(to: email, from: "FabLabs.io <[email protected]>", subject: "Account Recovery Instructions") | ||
end | ||
mail(to: emails, from: "FabLabs.io <[email protected]>", subject: "Account Recovery Instructions") | ||
rescue ActiveRecord::RecordNotFound | ||
end | ||
end | ||
|
This file contains 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 |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
describe UserMailer, type: :mailer do | ||
|
||
let(:user_emails) { ['[email protected]', '[email protected]'] } | ||
|
||
let(:lab) { FactoryBot.create(:lab) } | ||
let(:user) { FactoryBot.create(:user) } | ||
let(:user) { FactoryBot.create(:user, email: user_emails[0], email_fallback: user_emails[1]) } | ||
let(:employee) { FactoryBot.create(:employee, user: user, lab: lab) } | ||
|
||
%w( | ||
|
@@ -57,9 +59,16 @@ | |
recovery = FactoryBot.create(:recovery, user: user, email_or_username: [user.email, user.username].sample) | ||
mail = UserMailer.account_recovery_instructions(user.id) | ||
expect(mail.subject).to match("Account Recovery Instructions") | ||
expect(mail.to).to eq([user.email]) | ||
expect(mail.to).to eq(['email@bitsushi.com', '[email protected]']) | ||
expect(mail.from).to eq(["[email protected]"]) | ||
expect(mail.body.encoded).to match( recovery_url(user.recovery_key) ) | ||
end | ||
|
||
it "account_recovery_instructions_single" do | ||
simpleuser = FactoryBot.create(:user, email: '[email protected]') | ||
recovery = FactoryBot.create(:recovery, user: simpleuser, email_or_username: [simpleuser.email, simpleuser.username].sample) | ||
mail = UserMailer.account_recovery_instructions(simpleuser.id) | ||
expect(mail.to).to eq(['[email protected]']) | ||
end | ||
|
||
end |