forked from extern/django-helpdesk
0ac7183875
My browser sends 'on' when a checkbox is ticked, django ORM only recognises '1', 'true' or 't' as valid 'True' responses. This throws an error ValidationError at /helpdesk/save_query/ [u"'on' value must be either True or False."] This could be fixed with " value='1'" in the template, but testing that is harder My fix is to add a check in the view. 2 more lines, but easier to unittest. Core devs need to make a call as to which solution is best. D
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
from django.core.urlresolvers import reverse
|
|
from django.test import TestCase
|
|
from helpdesk.models import Ticket, Queue
|
|
from helpdesk.tests.helpers import get_staff_user, reload_urlconf
|
|
|
|
class TestSavingSharedQuery(TestCase):
|
|
def setUp(self):
|
|
q = Queue(title='Q1', slug='q1')
|
|
q.save()
|
|
self.q = q
|
|
|
|
def test_cansavequery(self):
|
|
"""Can a query be saved"""
|
|
url = reverse('helpdesk_savequery')
|
|
self.client.login(username=get_staff_user().get_username(),
|
|
password='password')
|
|
response = self.client.post(url,
|
|
data={'title': 'ticket on my queue',
|
|
'queue':self.q,
|
|
'shared':'on',
|
|
'query_encoded':'KGRwMApWZmlsdGVyaW5nCnAxCihkcDIKVnN0YXR1c19faW4KcDMKKGxwNApJMQphSTIKYUkzCmFzc1Zzb3J0aW5nCnA1ClZjcmVhdGVkCnA2CnMu'})
|
|
self.assertEqual(response.status_code, 302)
|
|
self.assertTrue('tickets/?saved_query=1' in response.url)
|
|
|
|
|