|
3 | 3 | RSpec.describe 'Resend confirmation' do |
4 | 4 | include_context 'with graphql query request' |
5 | 5 |
|
6 | | - let(:user) { create(:user, confirmed_at: nil) } |
| 6 | + let!(:user) { create(:user, confirmed_at: nil, email: 'mwallace@wallaceinc.com') } |
7 | 7 | let(:email) { user.email } |
8 | 8 | let(:id) { user.id } |
9 | 9 | let(:redirect) { Faker::Internet.url } |
|
28 | 28 | it 'sends an email to the user with confirmation url and returns a success message' do |
29 | 29 | expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1) |
30 | 30 | expect(json_response[:data][:userResendConfirmation]).to include( |
| 31 | + message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.', |
31 | 32 | authenticatable: { |
32 | | - id: id, |
| 33 | + id: id, |
33 | 34 | email: email |
34 | | - }, |
35 | | - message: "You will receive an email with instructions for how to confirm your email address in a few minutes." |
| 35 | + } |
36 | 36 | ) |
37 | | - |
| 37 | + |
38 | 38 | email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded) |
39 | 39 | link = email.css('a').first |
40 | 40 | confirm_link_msg_text = email.css('p')[1].inner_html |
41 | 41 | confirm_account_link_text = link.inner_html |
42 | 42 |
|
43 | | - expect(confirm_link_msg_text).to eq("You can confirm your account email through the link below:") |
44 | | - expect(confirm_account_link_text).to eq("Confirm my account") |
| 43 | + expect(confirm_link_msg_text).to eq('You can confirm your account email through the link below:') |
| 44 | + expect(confirm_account_link_text).to eq('Confirm my account') |
45 | 45 |
|
46 | 46 | # TODO: Move to feature spec |
47 | 47 | expect do |
|
50 | 50 | end.to change(user, :confirmed_at).from(NilClass).to(ActiveSupport::TimeWithZone) |
51 | 51 | end |
52 | 52 |
|
| 53 | + context 'when email address uses different casing' do |
| 54 | + let(:email) { 'mWallace@wallaceinc.com' } |
| 55 | + |
| 56 | + it 'honors devise configuration for case insensitive fields' do |
| 57 | + expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1) |
| 58 | + expect(json_response[:data][:userResendConfirmation]).to include( |
| 59 | + message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.', |
| 60 | + authenticatable: { |
| 61 | + id: id, |
| 62 | + email: user.email |
| 63 | + } |
| 64 | + ) |
| 65 | + end |
| 66 | + end |
| 67 | + |
53 | 68 | context 'when the user has already been confirmed' do |
54 | 69 | before { user.confirm } |
55 | 70 |
|
|
58 | 73 | expect(json_response[:data][:userResendConfirmation]).to be_nil |
59 | 74 | expect(json_response[:errors]).to contain_exactly( |
60 | 75 | hash_including( |
61 | | - message: "Email was already confirmed, please try signing in", |
| 76 | + message: 'Email was already confirmed, please try signing in', |
62 | 77 | extensions: { code: 'USER_ERROR' } |
63 | 78 | ) |
64 | 79 | ) |
|
74 | 89 | expect(json_response[:data][:userResendConfirmation]).to be_nil |
75 | 90 | expect(json_response[:errors]).to contain_exactly( |
76 | 91 | hash_including( |
77 | | - message: "Unable to find user with email '#{email}'.", |
| 92 | + message: "Unable to find user with email '#{email}'.", |
78 | 93 | extensions: { code: 'USER_ERROR' } |
79 | 94 | ) |
80 | 95 | ) |
|
0 commit comments