-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1288 from openstax/CORE-542-assignable-skip-pin-e…
…mail skip displaying the pin code text when creating external users
- Loading branch information
Showing
6 changed files
with
46 additions
and
15 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
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
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
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
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
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,9 +2,17 @@ | |
|
||
module Newflow | ||
describe NewflowMailer, type: :mailer do | ||
let(:pin) { '123456' } | ||
let(:code) { '1234' } | ||
let(:confirm_url) { "http://localhost:2999/i/verify_email_by_code/#{code}" } | ||
let(:user) { FactoryBot.create :user, first_name: 'John', last_name: 'Doe', suffix: 'Jr.' } | ||
let(:email) { FactoryBot.create :email_address, value: '[email protected]', | ||
user_id: user.id, confirmation_code: '1234', confirmation_pin: '123456' } | ||
let(:email) { | ||
FactoryBot.create :email_address, | ||
value: '[email protected]', | ||
user_id: user.id, | ||
confirmation_code: code, | ||
confirmation_pin: pin | ||
} | ||
|
||
describe 'sends email confirmation' do | ||
it 'has basic header and from info and greeting' do | ||
|
@@ -15,14 +23,34 @@ module Newflow | |
expect(mail.body.encoded).to include("Welcome to OpenStax!") | ||
end | ||
|
||
it "has PIN info" do | ||
allow(ConfirmByPin).to receive(:sequential_failure_for) { Hashie::Mash.new('attempts_remaining?' => true)} | ||
context 'when show_pin is not sent' do | ||
it 'includes PIN info in the email' do | ||
mail = NewflowMailer.signup_email_confirmation(email_address: email) | ||
|
||
mail = NewflowMailer.signup_email_confirmation email_address: email | ||
expect(mail.subject).to eq("[OpenStax] Your OpenStax account PIN has arrived: #{pin}") | ||
expect(mail.body.encoded).to include("<a href=\"#{confirm_url}\"") | ||
expect(mail.body.encoded).to include("use your pin: <b id='pin'>#{pin}</b>") | ||
end | ||
end | ||
|
||
context 'when show_pin is nil' do | ||
it 'includes PIN info in the email' do | ||
mail = NewflowMailer.signup_email_confirmation(email_address: email, show_pin: nil) | ||
|
||
expect(mail.subject).to eq("[OpenStax] Your OpenStax account PIN has arrived: #{pin}") | ||
expect(mail.body.encoded).to include("<a href=\"#{confirm_url}\"") | ||
expect(mail.body.encoded).to include("use your pin: <b id='pin'>#{pin}</b>") | ||
end | ||
end | ||
|
||
context 'when show_pin is false' do | ||
it 'excludes the pin code from the email' do | ||
mail = NewflowMailer.signup_email_confirmation(email_address: email, show_pin: false) | ||
|
||
expect(mail.subject).to eq("[OpenStax] Your OpenStax account PIN has arrived: 123456") | ||
expect(mail.body.encoded).to include('<a href="http://localhost:2999/i/verify_email_by_code/1234"') | ||
expect(mail.body.encoded).to include('use your pin: <b id=\'pin\'>123456</b>') | ||
expect(mail.subject).to eq("[OpenStax] Confirm your email address") | ||
expect(mail.body.encoded).to include("<a href=\"#{confirm_url}\"") | ||
expect(mail.body.encoded).not_to include("use your pin: <b id='pin'>#{pin}</b>") | ||
end | ||
end | ||
end | ||
end | ||
|