summaryrefslogtreecommitdiff
path: root/spec/mailers/emails/profile_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 14:34:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 14:34:42 +0000
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /spec/mailers/emails/profile_spec.rb
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
downloadgitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/mailers/emails/profile_spec.rb')
-rw-r--r--spec/mailers/emails/profile_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb
index 58c04fb4834..f84bf43b9c4 100644
--- a/spec/mailers/emails/profile_spec.rb
+++ b/spec/mailers/emails/profile_spec.rb
@@ -156,4 +156,44 @@ describe Emails::Profile do
it { expect { Notify.access_token_about_to_expire_email('foo') }.not_to raise_error }
end
end
+
+ describe 'user unknown sign in email' do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:ip) { '169.0.0.1' }
+
+ subject { Notify.unknown_sign_in_email(user, ip) }
+
+ it_behaves_like 'an email sent from GitLab'
+ it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like 'a user cannot unsubscribe through footer link'
+
+ it 'is sent to the user' do
+ expect(subject).to deliver_to user.email
+ end
+
+ it 'has the correct subject' do
+ expect(subject).to have_subject /^Unknown sign-in from new location$/
+ end
+
+ it 'mentions the unknown sign-in IP' do
+ expect(subject).to have_body_text /A sign-in to your account has been made from the following IP address: #{ip}./
+ end
+
+ it 'includes a link to the change password page' do
+ expect(subject).to have_body_text /#{edit_profile_password_path}/
+ end
+
+ it 'mentions two factor authentication when two factor is not enabled' do
+ expect(subject).to have_body_text /two-factor authentication/
+ end
+
+ context 'when two factor authentication is enabled' do
+ it 'does not mention two factor authentication' do
+ two_factor_user = create(:user, :two_factor)
+
+ expect( Notify.unknown_sign_in_email(two_factor_user, ip) )
+ .not_to have_body_text /two-factor authentication/
+ end
+ end
+ end
end