forked from extern/django-helpdesk
commit
03b3a70975
26
helpdesk/tests/test_savequery.py
Normal file
26
helpdesk/tests/test_savequery.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- 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)
|
||||||
|
|
||||||
|
|
@ -1213,6 +1213,8 @@ run_report = staff_member_required(run_report)
|
|||||||
def save_query(request):
|
def save_query(request):
|
||||||
title = request.POST.get('title', None)
|
title = request.POST.get('title', None)
|
||||||
shared = request.POST.get('shared', False)
|
shared = request.POST.get('shared', False)
|
||||||
|
if shared == 'on': # django only translates '1', 'true', 't' into True
|
||||||
|
shared = True
|
||||||
query_encoded = request.POST.get('query_encoded', None)
|
query_encoded = request.POST.get('query_encoded', None)
|
||||||
|
|
||||||
if not title or not query_encoded:
|
if not title or not query_encoded:
|
||||||
|
Loading…
Reference in New Issue
Block a user