allura
Revisión | e139cf7fcc8d150a1cd1e98d90e93f1f22b3b928 (tree) |
---|---|
Tiempo | 2012-07-11 11:54:49 |
Autor | Dave Brondsema <dbrondsema@geek...> |
Commiter | Dave Brondsema |
[#4272] add test for search_feed, and make valid rss/atom
@@ -659,6 +659,16 @@ class TestFunctionalController(TrackerTestController): | ||
659 | 659 | assert '3 results' in response, response.showbrowser() |
660 | 660 | assert 'test third ticket' in response, response.showbrowser() |
661 | 661 | |
662 | + def test_search_feed(self): | |
663 | + self.new_ticket(summary='test first ticket') | |
664 | + ThreadLocalORMSession.flush_all() | |
665 | + M.MonQTask.run_ready() | |
666 | + ThreadLocalORMSession.flush_all() | |
667 | + response = self.app.get('/p/test/bugs/search_feed?q=test') | |
668 | + assert '<title>test first ticket</title>' in response | |
669 | + response = self.app.get('/p/test/bugs/search_feed.atom?q=test') | |
670 | + assert '<title>test first ticket</title>' in response | |
671 | + | |
662 | 672 | def test_touch(self): |
663 | 673 | self.new_ticket(summary='test touch') |
664 | 674 | h.set_context('test', 'bugs', neighborhood='Projects') |
@@ -332,7 +332,7 @@ class RootController(BaseController): | ||
332 | 332 | return dict(bin_counts=bin_counts) |
333 | 333 | |
334 | 334 | def paged_query(self, q, limit=None, page=0, sort=None, columns=None, **kw): |
335 | - """Query tickets, sorting and paginating the result. | |
335 | + """Query tickets, filtering for 'read' permission, sorting and paginating the result. | |
336 | 336 | |
337 | 337 | We do the sorting and skipping right in SOLR, before we ever ask |
338 | 338 | Mongo for the actual tickets. Other keywords for |
@@ -523,17 +523,18 @@ class RootController(BaseController): | ||
523 | 523 | result = self.paged_query(q, page=page, sort=sort, columns=columns, **kw) |
524 | 524 | response.headers['Content-Type'] = '' |
525 | 525 | response.content_type = 'application/xml' |
526 | - d = dict(title='Ticket search results', link=c.app.url, description='You searched for %s' % q, language=u'en') | |
526 | + d = dict(title='Ticket search results', link=h.absurl(c.app.url), description='You searched for %s' % q, language=u'en') | |
527 | 527 | if request.environ['PATH_INFO'].endswith('.atom'): |
528 | 528 | feed = FG.Atom1Feed(**d) |
529 | 529 | else: |
530 | 530 | feed = FG.Rss201rev2Feed(**d) |
531 | 531 | for t in result['tickets']: |
532 | + url = h.absurl(t.url().encode('utf-8')) | |
532 | 533 | feed.add_item(title=t.summary, |
533 | - link=h.absurl(t.url().encode('utf-8')), | |
534 | + link=url, | |
534 | 535 | pubdate=t.mod_date, |
535 | 536 | description=t.description, |
536 | - unique_id=str(t._id), | |
537 | + unique_id=url, | |
537 | 538 | author_name=t.reported_by.display_name, |
538 | 539 | author_link=h.absurl(t.reported_by.url())) |
539 | 540 | return feed.writeString('utf-8') |