Add test for get_admin_display_title being used in explorer views

pull/3744/merge
Matt Westcott 2017-07-05 18:57:49 +01:00
rodzic 98c30a33e3
commit 4e5d6bcf12
2 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -305,6 +305,9 @@ class SingleEventPage(EventPage):
# fall back to default routing rules
return super(SingleEventPage, self).route(request, path_components)
def get_admin_display_title(self):
return "%s (single event)" % super(SingleEventPage, self).get_admin_display_title()
SingleEventPage.content_panels = [FieldPanel('excerpt')] + EventPage.content_panels

Wyświetl plik

@ -251,6 +251,22 @@ class TestPageExplorer(TestCase, WagtailTestUtils):
self.assertContains(response, '/new-event/pointless-suffix/')
def test_listing_uses_admin_display_title(self):
# SingleEventPage has a custom get_admin_display_title method; explorer should
# show the custom title rather than the basic database one
self.new_event = SingleEventPage(
title="New event",
location='the moon', audience='public',
cost='free', date_from='2001-01-01',
latest_revision_created_at=local_datetime(2016, 1, 1)
)
self.root_page.add_child(instance=self.new_event)
response = self.client.get(reverse('wagtailadmin_explore', args=(self.root_page.id, )))
self.assertContains(response, 'New event (single event)')
response = self.client.get(reverse('wagtailadmin_explore', args=(self.new_event.id, )))
self.assertContains(response, 'New event (single event)')
def test_parent_page_is_specific(self):
response = self.client.get(reverse('wagtailadmin_explore', args=(self.child_page.id, )))
self.assertEqual(response.status_code, 200)