Skip to content

Commit 0745ae5

Browse files
committed
Test that validation is still enforced on save_revision when saving or scheduling
As per wagtail/rfcs#104 (comment) - unless clean=False is explicitly passed, validation should be applied, including on fields that would accept nulls at the database level.
1 parent 2b88274 commit 0745ae5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

wagtail/tests/test_page_model.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,20 @@ def test_raises_error_if_non_specific_page_used(self):
982982
"page.save_revision() must be called on the specific version of the page. Call page.specific.save_revision() instead.",
983983
)
984984

985+
def test_validate_on_save_revision(self):
986+
christmas_event = EventPage.objects.get(url_path="/home/events/christmas/")
987+
christmas_event.date_from = None
988+
with self.assertRaises(ValidationError):
989+
christmas_event.save_revision()
990+
991+
def test_validate_on_schedule_revision(self):
992+
christmas_event = EventPage.objects.get(url_path="/home/events/christmas/")
993+
christmas_event.date_from = None
994+
with self.assertRaises(ValidationError):
995+
christmas_event.save_revision(
996+
approved_go_live_at=timezone.now() + datetime.timedelta(days=1)
997+
)
998+
985999

9861000
class TestLiveRevision(TestCase):
9871001
fixtures = ["test.json"]

0 commit comments

Comments
 (0)