diff --git a/app/main/views/code_not_received.py b/app/main/views/code_not_received.py index a644e3f34..25e2f060a 100644 --- a/app/main/views/code_not_received.py +++ b/app/main/views/code_not_received.py @@ -49,7 +49,8 @@ def check_and_resend_verification_code(): @main.route('/email-not-received', methods=['GET']) @redirect_to_sign_in def email_not_received(): - return render_template('views/email-not-received.html') + redirect_url = request.args.get('next') + return render_template('views/email-not-received.html', redirect_url=redirect_url) @main.route('/send-new-email-token', methods=['GET']) diff --git a/app/templates/views/email-not-received.html b/app/templates/views/email-not-received.html index f7eb1dd96..a6ddc8881 100644 --- a/app/templates/views/email-not-received.html +++ b/app/templates/views/email-not-received.html @@ -16,7 +16,7 @@ {{ govukButton({ "element": "a", "text": "Resend email link", - "href": url_for('main.resend_email_link') + "href": url_for('main.resend_email_link', next=redirect_url) }) }}

diff --git a/tests/app/main/views/test_code_not_received.py b/tests/app/main/views/test_code_not_received.py index 143392987..6e8a2b245 100644 --- a/tests/app/main/views/test_code_not_received.py +++ b/tests/app/main/views/test_code_not_received.py @@ -176,3 +176,28 @@ def test_redirect_to_sign_in_if_not_logged_in( assert response.location == url_for('main.sign_in', _external=True) assert response.status_code == 302 + + +@pytest.mark.parametrize('redirect_url', [ + None, + 'blob', +]) +def test_should_render_correct_email_not_received_template_for_active_user( + client, + api_user_active, + mock_get_user_by_email, + mock_send_verify_code, + redirect_url +): + with client.session_transaction() as session: + session['user_details'] = { + 'id': api_user_active['id'], + 'email': api_user_active['email_address']} + response = client.get(url_for('main.email_not_received', next=redirect_url)) + assert response.status_code == 200 + + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.h1.string == 'Resend email link' + # there shouldn't be a form for updating mobile number + assert page.find('form') is None + assert page.find('a', class_="govuk-button")['href'] == url_for('main.resend_email_link', next=redirect_url)