-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7753 from edx/aj/tnl1745-change-email-on-dashboard
Fixed change email address error from student dashboard
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,6 +243,32 @@ def test_invalid_password(self): | |
self.request.POST['password'] = 'wrong' | ||
self.assertFailedRequest(self.run_request(), 'Invalid password') | ||
|
||
@patch('student.views.render_to_string', Mock(side_effect=mock_render_to_string, autospec=True)) | ||
def test_duplicate_activation_key(self): | ||
"""Assert that if two users change Email address simultaneously, server should return 200""" | ||
|
||
# New emails for the users | ||
user1_new_email = "[email protected]" | ||
user2_new_email = "[email protected]" | ||
|
||
# Set new email for user1. | ||
self.request.POST['new_email'] = user1_new_email | ||
|
||
# Create a another user 'user2' & make request for change email | ||
user2 = UserFactory.create(email=self.new_email, password="test2") | ||
user2_request = self.req_factory.post('unused_url', data={ | ||
'password': 'test2', | ||
'new_email': user2_new_email | ||
}) | ||
user2_request.user = user2 | ||
|
||
# Send requests & check if response was successful | ||
user1_response = change_email_request(self.request) | ||
user2_response = change_email_request(user2_request) | ||
|
||
self.assertEqual(user1_response.status_code, 200) | ||
self.assertEqual(user2_response.status_code, 200) | ||
|
||
def test_invalid_emails(self): | ||
for email in ('bad_email', 'bad_email@', '@bad_email'): | ||
self.request.POST['new_email'] = email | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters