Test that validation is still enforced on save_revision when saving or scheduling

As per https://github.com/wagtail/rfcs/pull/104#issuecomment-2691145020 - unless clean=False is explicitly passed, validation should be applied, including on fields that would accept nulls at the database level.
pull/12964/head
Matt Westcott 2025-03-01 00:01:45 +00:00 zatwierdzone przez Matt Westcott
rodzic 2b882743ec
commit 0745ae53da
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -982,6 +982,20 @@ class TestSaveRevision(TestCase):
"page.save_revision() must be called on the specific version of the page. Call page.specific.save_revision() instead.",
)
def test_validate_on_save_revision(self):
christmas_event = EventPage.objects.get(url_path="/home/events/christmas/")
christmas_event.date_from = None
with self.assertRaises(ValidationError):
christmas_event.save_revision()
def test_validate_on_schedule_revision(self):
christmas_event = EventPage.objects.get(url_path="/home/events/christmas/")
christmas_event.date_from = None
with self.assertRaises(ValidationError):
christmas_event.save_revision(
approved_go_live_at=timezone.now() + datetime.timedelta(days=1)
)
class TestLiveRevision(TestCase):
fixtures = ["test.json"]