summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2013-06-13 18:37:08 +0200
committerTim Graham <timograham@gmail.com>2013-06-13 13:31:57 -0400
commitdc9c359546580d40df209816cef244b78dcf7435 (patch)
tree88e146d707a66c033321050b6737e17b09226f59 /tests
parent675558d00efab507ef2e538025f20abc6725b159 (diff)
Fixed #20594 -- Add validation to models.SlugField.
Thanks carbonXT for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/models.py1
-rw-r--r--tests/validation/tests.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/tests/validation/models.py b/tests/validation/models.py
index e95a1e0744..958740dd2d 100644
--- a/tests/validation/models.py
+++ b/tests/validation/models.py
@@ -19,6 +19,7 @@ class ModelToValidate(models.Model):
email = models.EmailField(blank=True)
url = models.URLField(blank=True)
f_with_custom_validator = models.IntegerField(blank=True, null=True, validators=[validate_answer_to_universe])
+ slug = models.SlugField(blank=True)
def clean(self):
super(ModelToValidate, self).clean()
diff --git a/tests/validation/tests.py b/tests/validation/tests.py
index 9ddf796c2b..c8b679541a 100644
--- a/tests/validation/tests.py
+++ b/tests/validation/tests.py
@@ -53,7 +53,11 @@ class BaseModelValidationTests(ValidationTestCase):
def test_text_greater_that_charfields_max_length_raises_erros(self):
mtv = ModelToValidate(number=10, name='Some Name'*100)
- self.assertFailsValidation(mtv.full_clean, ['name',])
+ self.assertFailsValidation(mtv.full_clean, ['name'])
+
+ def test_malformed_slug_raises_error(self):
+ mtv = ModelToValidate(number=10, name='Some Name', slug='##invalid##')
+ self.assertFailsValidation(mtv.full_clean, ['slug'])
class ArticleForm(forms.ModelForm):