diff options
Diffstat (limited to 'spec/features/users/email_verification_on_login_spec.rb')
-rw-r--r-- | spec/features/users/email_verification_on_login_spec.rb | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/spec/features/users/email_verification_on_login_spec.rb b/spec/features/users/email_verification_on_login_spec.rb index c8301c2fc91..f7102eaf9b7 100644 --- a/spec/features/users/email_verification_on_login_spec.rb +++ b/spec/features/users/email_verification_on_login_spec.rb @@ -118,7 +118,7 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting # Expect an error message expect_log_message('Failed Attempt', reason: 'rate_limited') expect(page).to have_content("You've reached the maximum amount of tries. "\ - 'Wait 10 minutes or resend a new code and try again.') + 'Wait 10 minutes or send a new code and try again.') # Wait for 10 minutes travel 10.minutes @@ -138,7 +138,7 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting # Expect an error message expect_log_message('Failed Attempt', reason: 'invalid') - expect(page).to have_content('The code is incorrect. Enter it again, or resend a new code.') + expect(page).to have_content('The code is incorrect. Enter it again, or send a new code.') end it 'verifies expired codes' do @@ -150,12 +150,12 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting code = expect_instructions_email_and_extract_code # Wait for the code to expire before verifying - travel VerifiesWithEmail::TOKEN_VALID_FOR_MINUTES.minutes + 1.second + travel Users::EmailVerification::ValidateTokenService::TOKEN_VALID_FOR_MINUTES.minutes + 1.second verify_code(code) # Expect an error message expect_log_message('Failed Attempt', reason: 'expired') - expect(page).to have_content('The code has expired. Resend a new code and try again.') + expect(page).to have_content('The code has expired. Send a new code and try again.') end end end @@ -255,7 +255,7 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting perform_enqueued_jobs do # The user is prompted for a verification code gitlab_sign_in(user) - expect(page).to have_content('Help us protect your account') + expect(page).to have_content(s_('IdentityVerification|Help us protect your account')) code = expect_instructions_email_and_extract_code # We toggle the feature flag off @@ -266,12 +266,13 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting new_code = expect_instructions_email_and_extract_code verify_code(code) - expect(page).to have_content('The code is incorrect. Enter it again, or resend a new code.') + expect(page) + .to have_content(s_('IdentityVerification|The code is incorrect. Enter it again, or send a new code.')) - travel VerifiesWithEmail::TOKEN_VALID_FOR_MINUTES.minutes + 1.second + travel Users::EmailVerification::ValidateTokenService::TOKEN_VALID_FOR_MINUTES.minutes + 1.second verify_code(new_code) - expect(page).to have_content('The code has expired. Resend a new code and try again.') + expect(page).to have_content(s_('IdentityVerification|The code has expired. Send a new code and try again.')) click_link 'Resend code' another_code = expect_instructions_email_and_extract_code @@ -296,7 +297,7 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting it 'the unlock link still works' do # The user is locked and unlock instructions are sent - expect(page).to have_content('Invalid login or password.') + expect(page).to have_content(_('Invalid login or password.')) user.reload expect(user.locked_at).not_to be_nil expect(user.unlock_token).not_to be_nil @@ -334,24 +335,24 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting def expect_instructions_email_and_extract_code mail = find_email_for(user) expect(mail.to).to match_array([user.email]) - expect(mail.subject).to eq('Verify your identity') - code = mail.body.parts.first.to_s[/\d{#{VerifiesWithEmail::TOKEN_LENGTH}}/o] + expect(mail.subject).to eq(s_('IdentityVerification|Verify your identity')) + code = mail.body.parts.first.to_s[/\d{#{Users::EmailVerification::GenerateTokenService::TOKEN_LENGTH}}/o] reset_delivered_emails! code end def verify_code(code) - fill_in 'Verification code', with: code - click_button 'Verify code' + fill_in s_('IdentityVerification|Verification code'), with: code + click_button s_('IdentityVerification|Verify code') end def expect_log_message(event = nil, times = 1, reason: '', message: nil) expect(Gitlab::AppLogger).to have_received(:info) .exactly(times).times .with(message || hash_including(message: 'Email Verification', - event: event, - username: user.username, - ip: '127.0.0.1', - reason: reason)) + event: event, + username: user.username, + ip: '127.0.0.1', + reason: reason)) end end |