diff options
| author | Basil Dubyk <samitnuk.work@gmail.com> | 2018-11-09 22:41:55 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-11-28 15:40:14 -0500 |
| commit | 7d1123e5ada60963ba3c708a8932e57342278706 (patch) | |
| tree | 76d204ee4a8e4887a7dfe89631c2688f9622345d /tests/admin_views/tests.py | |
| parent | 682cdf6cab8cb76ef1808df45631c39748052e13 (diff) | |
Fixed #29929 -- Fixed admin view-only change form crash when using ModelAdmin.prepopulated_fields.
Diffstat (limited to 'tests/admin_views/tests.py')
| -rw-r--r-- | tests/admin_views/tests.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index fb10f485cd..115291f902 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -4211,6 +4211,25 @@ class PrePopulatedTest(TestCase): response = self.client.get(reverse('admin:admin_views_prepopulatedpostlargeslug_add')) self.assertContains(response, ""maxLength": 1000") # instead of 1,000 + def test_view_only_add_form(self): + """ + PrePopulatedPostReadOnlyAdmin.prepopulated_fields includes 'slug' + which is present in the add view, even if the + ModelAdmin.has_change_permission() returns False. + """ + response = self.client.get(reverse('admin7:admin_views_prepopulatedpost_add')) + self.assertContains(response, 'data-prepopulated-fields=') + self.assertContains(response, '"id": "#id_slug"') + + def test_view_only_change_form(self): + """ + PrePopulatedPostReadOnlyAdmin.prepopulated_fields includes 'slug'. That + doesn't break a view-only change view. + """ + response = self.client.get(reverse('admin7:admin_views_prepopulatedpost_change', args=(self.p1.pk,))) + self.assertContains(response, 'data-prepopulated-fields="[]"') + self.assertContains(response, '<div class="readonly">%s</div>' % self.p1.slug) + @override_settings(ROOT_URLCONF='admin_views.urls') class SeleniumTests(AdminSeleniumTestCase): |
