Skip to content

Commit

Permalink
[588228] Force num_voted to 0 if None or ''
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Craciunoiu committed Aug 24, 2010
1 parent 5f577cb commit 6975470
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/search/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
DiscussionClient, SearchError)
from sumo.models import WikiPage
from forums.models import Post
import forums.tests as forum_tests


def render(s, context):
Expand Down Expand Up @@ -148,7 +147,7 @@ class SphinxTestCase(test_utils.TransactionTestCase):
"""

fixtures = ['pages.json', 'categories.json', 'users.json',
'posts.json', 'questions.json',]
'posts.json', 'questions.json', ]
sphinx = True
sphinx_is_running = False

Expand Down Expand Up @@ -316,6 +315,11 @@ def test_sort_mode(self):
results[-1]['attrs'][test_for[i]])
i += 1

def test_num_voted_none(self):
qs = {'q': '', 'w': 2, 'a': 1, 'num_voted': 2, 'num_votes': ''}
response = self.client.get(reverse('search'), qs)
eq_(200, response.status_code)

def test_created(self):
"""Basic functionality of created filter."""

Expand Down
2 changes: 2 additions & 0 deletions apps/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def clean(self):
cleaned_data[field_option] = None

# Validate all integer fields
if not cleaned_data.get('num_votes'):
cleaned_data['num_votes'] = 0

# Set defaults for MultipleChoiceFields and convert to ints.
# Ticket #12398 adds TypedMultipleChoiceField which would replace
Expand Down

0 comments on commit 6975470

Please sign in to comment.