Welcome to mirror list, hosted at ThFree Co, Russian Federation.

identity_verification_spec.rb « emails « mailers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 57ae95cc1eeb83a47312d142cf61d74f6ce92fe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Emails::IdentityVerification do
  include EmailSpec::Matchers
  include_context 'gitlab email notification'

  describe 'verification_instructions_email' do
    let_it_be(:user) { build_stubbed(:user) }
    let_it_be(:token) { '123456' }

    subject do
      Notify.verification_instructions_email(user.email, token: token)
    end

    it_behaves_like 'an email sent from GitLab'

    it 'is sent to the user' do
      is_expected.to deliver_to user.email
    end

    it 'has the correct subject' do
      is_expected.to have_subject s_('IdentityVerification|Verify your identity')
    end

    it 'has the mailgun suppression bypass header' do
      is_expected.to have_header 'X-Mailgun-Suppressions-Bypass', 'true'
    end

    it 'includes the token' do
      is_expected.to have_body_text token
    end

    it 'includes the expiration time' do
      expires_in_minutes = Users::EmailVerification::ValidateTokenService::TOKEN_VALID_FOR_MINUTES

      is_expected.to have_body_text format(s_('IdentityVerification|Your verification code expires after '\
        '%{expires_in_minutes} minutes.'), expires_in_minutes: expires_in_minutes)
    end
  end
end