mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 13:09:42 -04:00
Check that user isn’t signed in before registering
Previously this test asserted on `current_user.is_authenticated`. That
isn’t possible now because the object imported into tests isn’t the same
one the app is using.
A different proxy for whether the user is signed in is whether they have
a user id in their session, because we set this every time they sign in:
ff32e73d9b/app/models/user.py (L162)
This commit is contained in:
@@ -340,6 +340,8 @@ def test_register_from_email_auth_invite(
|
||||
sample_invite['email_address'] = invite_email_address
|
||||
with client.session_transaction() as session:
|
||||
session['invited_user_id'] = sample_invite['id']
|
||||
# Prove that the user isn’t already signed in
|
||||
assert 'user_id' not in session
|
||||
|
||||
data = {
|
||||
'name': 'invited user',
|
||||
@@ -382,6 +384,8 @@ def test_register_from_email_auth_invite(
|
||||
)
|
||||
|
||||
with client.session_transaction() as session:
|
||||
# The user is signed in
|
||||
assert 'user_id' in session
|
||||
# invited user details are still there so they can get added to the service
|
||||
assert session['invited_user_id'] == sample_invite['id']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user