Fix a bug with inviting existing users to an organisation.

The method to add the user to the organisation was missing the user id. This PR fixes that.
This commit is contained in:
Rebecca Law
2019-06-27 15:34:23 +01:00
parent 149003c52c
commit d344bc7006
3 changed files with 6 additions and 6 deletions

View File

@@ -105,7 +105,7 @@ def accept_org_invite(token):
if existing_user:
invited_org_user.accept_invite()
if existing_user not in organisation_users:
invited_org_user.add_to_organisation()
invited_org_user.add_to_organisation(existing_user.id)
return redirect(url_for('main.organisation_dashboard', org_id=invited_org_user.organisation))
else:
return redirect(url_for('main.register_from_org_invite'))

View File

@@ -584,8 +584,8 @@ class InvitedOrgUser(JSONModel):
def accept_invite(self):
org_invite_api_client.accept_invite(self.organisation, self.id)
def add_to_organisation(self):
user_api_client.add_user_to_organisation(self.organisation, self.id)
def add_to_organisation(self, user_id):
user_api_client.add_user_to_organisation(self.organisation, user_id)
class AnonymousUser(AnonymousUserMixin):

View File

@@ -1,6 +1,5 @@
from datetime import datetime, timedelta
from unittest.mock import ANY
from uuid import UUID
import pytest
from bs4 import BeautifulSoup
@@ -84,7 +83,7 @@ def test_invite_org_user_errors_when_same_email_as_inviter(
assert normalize_spaces(page.select_one('.error-message').text) == 'You cant send an invitation to yourself'
def test_accepted_invite_when_user_already_logged_in(
def test_accepted_invite_when_other_user_already_logged_in(
client_request,
mock_check_org_invite_token
):
@@ -165,6 +164,7 @@ def test_existing_user_invite_already_is_member_of_organisation(
def test_existing_user_invite_not_a_member_of_organisation(
client,
api_user_active,
mock_check_org_invite_token,
mock_get_user_by_email,
mock_get_users_for_organisation,
@@ -186,7 +186,7 @@ def test_existing_user_invite_not_a_member_of_organisation(
mock_get_users_for_organisation.assert_called_once_with(ORGANISATION_ID)
mock_add_user_to_organisation.assert_called_once_with(
ORGANISATION_ID,
str(UUID(bytes=b'sample_org_invit', version=4))
api_user_active['id'],
)