Skip to content

Commit

Permalink
1.1.2dev: Merged [11823:11825] from 1.0-stable (fix for #11152).
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.edgewall.org/repos/trac/trunk@11845 af82e41b-90c4-0310-8c96-b1721e28e2e2
  • Loading branch information
rjollos committed Jul 12, 2013
1 parent 595e304 commit e28e0d7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
8 changes: 8 additions & 0 deletions trac/tests/functional/tester.py
Expand Up @@ -135,6 +135,14 @@ def go_to_timeline(self):
tc.follow('Timeline')
tc.url(self.url + '/timeline')

def go_to_view_tickets(self, href='report'):
"""Surf to the View Tickets page. By default this will be the Reports
page, but 'query' can be specified for the `href` argument to support
non-default configurations."""
self.go_to_front()
tc.follow('View Tickets')
tc.url(self.url + '/' + href.lstrip('/'))

def go_to_query(self):
"""Surf to the custom query page."""
self.go_to_front()
Expand Down
3 changes: 2 additions & 1 deletion trac/ticket/query.py
Expand Up @@ -868,7 +868,8 @@ def get_active_navigation_item(self, req):
def get_navigation_items(self, req):
from trac.ticket.report import ReportModule
if 'TICKET_VIEW' in req.perm and \
not self.env.is_component_enabled(ReportModule):
not (self.env.is_component_enabled(ReportModule) and
'REPORT_VIEW' in req.perm):
yield ('mainnav', 'tickets',
tag.a(_('View Tickets'), href=req.href.query()))

Expand Down
38 changes: 38 additions & 0 deletions trac/ticket/tests/functional.py
Expand Up @@ -1753,6 +1753,43 @@ def runTest(self):
('ROADMAP_VIEW', 'MILESTONE_VIEW'))


class RegressionTestTicket11153(FunctionalTwillTestCaseSetup):
def runTest(self):
"""Test for regression of http://trac.edgewall.org/ticket/11153"""
# Check that "View Tickets" mainnav entry links to the report page
self._tester.go_to_view_tickets()

# Check that "View Tickets" mainnav entry links to the query page
# when the user doesn't have REPORT_VIEW, and that the mainnav entry
# is not present when the user doesn't have TICKET_VIEW.
try:
self._tester.logout()
self._testenv.revoke_perm('anonymous', 'REPORT_VIEW')
self._tester.go_to_view_tickets('query')

self._testenv.revoke_perm('anonymous', 'TICKET_VIEW')
self._tester.go_to_front()
tc.notfind('\\bView Tickets\\b')
finally:
self._testenv.grant_perm('anonymous',
('REPORT_VIEW', 'TICKET_VIEW'))
self._tester.login('admin')

# Disable the ReportModule component and check that "View Tickets"
# mainnav entry links to the `/query` page.
env = self._testenv.get_trac_environment()
env.config.set('components', 'trac.ticket.report.ReportModule',
'disabled')
env.config.save()
self._testenv.restart()
try:
self._tester.go_to_view_tickets('query')
finally:
env.config.remove('components', 'trac.ticket.report.ReportModule')
env.config.save()
self._testenv.restart()


def functionalSuite(suite=None):
if not suite:
import trac.tests.functional.testcases
Expand Down Expand Up @@ -1853,6 +1890,7 @@ def functionalSuite(suite=None):
suite.addTest(RegressionTestTicket9084())
suite.addTest(RegressionTestTicket9981())
suite.addTest(RegressionTestTicket11028())
suite.addTest(RegressionTestTicket11153())

return suite

Expand Down

0 comments on commit e28e0d7

Please sign in to comment.