|
21 | 21 | end |
22 | 22 |
|
23 | 23 | context 'when params are correct' do |
24 | | - it 'sends an email to the user with confirmation url and returns a success message' do |
25 | | - expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1) |
26 | | - expect(json_response[:data][:userResendConfirmation]).to include( |
27 | | - message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.' |
28 | | - ) |
| 24 | + context 'when using the gem schema' do |
| 25 | + it 'sends an email to the user with confirmation url and returns a success message' do |
| 26 | + expect { post_request }.to change(ActionMailer::Base.deliveries, :count).by(1) |
| 27 | + expect(json_response[:data][:userResendConfirmation]).to include( |
| 28 | + message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.' |
| 29 | + ) |
| 30 | + |
| 31 | + email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded) |
| 32 | + link = email.css('a').first |
| 33 | + confirm_link_msg_text = email.css('p')[1].inner_html |
| 34 | + confirm_account_link_text = link.inner_html |
| 35 | + |
| 36 | + expect(link['href']).to include('/api/v1/graphql_auth?') |
| 37 | + expect(confirm_link_msg_text).to eq('You can confirm your account email through the link below:') |
| 38 | + expect(confirm_account_link_text).to eq('Confirm my account') |
| 39 | + |
| 40 | + expect do |
| 41 | + get link['href'] |
| 42 | + user.reload |
| 43 | + end.to change(user, :confirmed_at).from(NilClass).to(ActiveSupport::TimeWithZone) |
| 44 | + end |
| 45 | + end |
| 46 | + |
| 47 | + context 'when using a custom schema' do |
| 48 | + let(:custom_path) { '/api/v1/graphql' } |
| 49 | + |
| 50 | + it 'sends an email to the user with confirmation url and returns a success message' do |
| 51 | + expect { post_request(custom_path) }.to change(ActionMailer::Base.deliveries, :count).by(1) |
| 52 | + expect(json_response[:data][:userResendConfirmation]).to include( |
| 53 | + message: 'You will receive an email with instructions for how to confirm your email address in a few minutes.' |
| 54 | + ) |
29 | 55 |
|
30 | | - email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded) |
31 | | - link = email.css('a').first |
32 | | - confirm_link_msg_text = email.css('p')[1].inner_html |
33 | | - confirm_account_link_text = link.inner_html |
| 56 | + email = Nokogiri::HTML(ActionMailer::Base.deliveries.last.body.encoded) |
| 57 | + link = email.css('a').first |
| 58 | + confirm_link_msg_text = email.css('p')[1].inner_html |
| 59 | + confirm_account_link_text = link.inner_html |
34 | 60 |
|
35 | | - expect(confirm_link_msg_text).to eq('You can confirm your account email through the link below:') |
36 | | - expect(confirm_account_link_text).to eq('Confirm my account') |
| 61 | + expect(link['href']).to include("#{custom_path}?") |
| 62 | + expect(confirm_link_msg_text).to eq('You can confirm your account email through the link below:') |
| 63 | + expect(confirm_account_link_text).to eq('Confirm my account') |
37 | 64 |
|
38 | | - # TODO: Move to feature spec |
39 | | - expect do |
40 | | - get link['href'] |
41 | | - user.reload |
42 | | - end.to change(user, :confirmed_at).from(NilClass).to(ActiveSupport::TimeWithZone) |
| 65 | + expect do |
| 66 | + get link['href'] |
| 67 | + user.reload |
| 68 | + end.to change(user, :confirmed_at).from(NilClass).to(ActiveSupport::TimeWithZone) |
| 69 | + end |
43 | 70 | end |
44 | 71 |
|
45 | 72 | context 'when email address uses different casing' do |
|
0 commit comments