-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent duplicate reviewers; enforce reviewer uniqueness in model
- Loading branch information
Jiri Suchan
committed
Aug 24, 2019
1 parent
23b81d7
commit bb17d7e
Showing
3 changed files
with
43 additions
and
4 deletions.
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ class TestAdminViews(TestCase): | |
fixtures = ['test.json'] | ||
|
||
def setUp(self): | ||
User.objects.create_superuser(username='admin', email='[email protected]', password='password') | ||
self.user = User.objects.create_superuser(username='admin', email='[email protected]', password='password') | ||
self.assertTrue( | ||
self.client.login(username='admin', password='password') | ||
) | ||
|
@@ -128,11 +128,12 @@ def test_post_edit_form(self): | |
self.assertEqual(email_recipients, {'[email protected]', '[email protected]'}) | ||
|
||
def test_post_create_form(self): | ||
review_user = User.objects.get(username='spongebob') | ||
response = self.client.post('/admin/pages/add/tests/simplepage/2/', { | ||
'title': "Subpage submitted", | ||
'slug': 'subpage-submitted', | ||
|
||
'create_review_reviewers-TOTAL_FORMS': 2, | ||
'create_review_reviewers-TOTAL_FORMS': 4, | ||
'create_review_reviewers-INITIAL_FORMS': 0, | ||
'create_review_reviewers-MIN_NUM_FORMS': 0, | ||
'create_review_reviewers-MAX_NUM_FORMS': 1000, | ||
|
@@ -141,10 +142,18 @@ def test_post_create_form(self): | |
'create_review_reviewers-0-email': '[email protected]', | ||
'create_review_reviewers-0-DELETE': '', | ||
|
||
'create_review_reviewers-1-user': User.objects.get(username='spongebob').pk, | ||
'create_review_reviewers-1-user': review_user.pk, | ||
'create_review_reviewers-1-email': '', | ||
'create_review_reviewers-1-DELETE': '', | ||
|
||
'create_review_reviewers-2-user': review_user.pk, | ||
'create_review_reviewers-2-email': '', | ||
'create_review_reviewers-2-DELETE': '', | ||
|
||
'create_review_reviewers-3-user': self.user.pk, | ||
'create_review_reviewers-3-email': self.user.email, | ||
'create_review_reviewers-3-DELETE': '', | ||
|
||
'action-submit-for-review': '1', | ||
}) | ||
|
||
|
@@ -160,3 +169,6 @@ def test_post_create_form(self): | |
self.assertEqual(len(mail.outbox), 2) | ||
email_recipients = set(email.to[0] for email in mail.outbox) | ||
self.assertEqual(email_recipients, {'[email protected]', '[email protected]'}) | ||
|
||
review_view = self.client.get('/admin/wagtail_review/reviews/%s/view/' % review.pk) | ||
self.assertEqual(review_view.status_code, 200) |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 2.2.4 on 2019-08-23 16:37 | ||
|
||
from django.conf import settings | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('wagtail_review', '0003_response'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterUniqueTogether( | ||
name='reviewer', | ||
unique_together={('review', 'user')}, | ||
), | ||
] |
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