-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InykoaMarkup: Dont strip whitespace in form fields
Otherwise valid InyokaMarkup like ``` * a * b ``` will be rendered wrong, as the space before `* a` is stripped. The `validate_empty_text` validator of `StrippedCharField` assures that still no empty content can be submitted. Fix #1335
- Loading branch information
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
tests.apps.ikhaya.test_views | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Test ikhaya forms. | ||
:copyright: (c) 2012-2024 by the Inyoka Team, see AUTHORS for more details. | ||
:license: BSD, see LICENSE for more details. | ||
""" | ||
|
||
from inyoka.ikhaya.forms import EditCommentForm | ||
from inyoka.utils.test import TestCase | ||
|
||
|
||
class TestEditCommentForm(TestCase): | ||
form = EditCommentForm | ||
|
||
def test_text__whitespace_not_stripped(self): | ||
text = ' * a \n * b\n' | ||
data = {'text': text} | ||
|
||
form = self.form(data) | ||
|
||
self.assertTrue(form.is_valid()) | ||
self.assertEqual(form.cleaned_data['text'], text) | ||
|
||
def test_text__empty_text_rejected(self): | ||
text = ' \n \t' | ||
data = {'text': text} | ||
|
||
form = self.form(data) | ||
|
||
self.assertFalse(form.is_valid()) | ||
self.assertIn( | ||
'Text must not be empty', | ||
form.errors['text'], | ||
) |