mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 09:18:24 -04:00
Merge pull request #1251 from alphagov/fix-500-registration-continue
Fix 500 error if revisiting registration page
This commit is contained in:
@@ -89,4 +89,6 @@ def _do_registration(form, service=None, send_sms=True, send_email=True):
|
|||||||
|
|
||||||
@main.route('/registration-continue')
|
@main.route('/registration-continue')
|
||||||
def registration_continue():
|
def registration_continue():
|
||||||
|
if not session.get('user_details'):
|
||||||
|
return redirect(url_for('.show_all_services_or_dashboard'))
|
||||||
return render_template('views/registration-continue.html')
|
return render_template('views/registration-continue.html')
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from unittest.mock import ANY
|
||||||
|
|
||||||
from flask import (
|
from flask import (
|
||||||
url_for,
|
url_for,
|
||||||
@@ -43,11 +45,12 @@ def test_register_creates_new_user_and_redirects_to_continue_page(
|
|||||||
'password': 'validPassword!'
|
'password': 'validPassword!'
|
||||||
}
|
}
|
||||||
|
|
||||||
response = client.post(url_for('main.register'), data=user_data)
|
response = client.post(url_for('main.register'), data=user_data, follow_redirects=True)
|
||||||
assert response.status_code == 302
|
assert response.status_code == 200
|
||||||
assert response.location == url_for('main.registration_continue', _external=True)
|
|
||||||
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
assert page.select('main p')[0].text == 'An email has been sent to notfound@example.gov.uk.'
|
||||||
|
|
||||||
from unittest.mock import ANY
|
|
||||||
mock_send_verify_email.assert_called_with(ANY, user_data['email_address'])
|
mock_send_verify_email.assert_called_with(ANY, user_data['email_address'])
|
||||||
mock_register_user.assert_called_with(user_data['name'],
|
mock_register_user.assert_called_with(user_data['name'],
|
||||||
user_data['email_address'],
|
user_data['email_address'],
|
||||||
@@ -55,6 +58,15 @@ def test_register_creates_new_user_and_redirects_to_continue_page(
|
|||||||
user_data['password'])
|
user_data['password'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_register_continue_handles_missing_session_sensibly(
|
||||||
|
client,
|
||||||
|
):
|
||||||
|
# session is not set
|
||||||
|
response = client.get(url_for('main.registration_continue'))
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert response.location == url_for('main.show_all_services_or_dashboard', _external=True)
|
||||||
|
|
||||||
|
|
||||||
def test_process_register_returns_200_when_mobile_number_is_invalid(
|
def test_process_register_returns_200_when_mobile_number_is_invalid(
|
||||||
client,
|
client,
|
||||||
mock_send_verify_code,
|
mock_send_verify_code,
|
||||||
|
|||||||
Reference in New Issue
Block a user