Merge lp:~stevenk/launchpad/link-bug-tags-correctly-redux into lp:launchpad

Proposed by Steve Kowalik on 2012-01-25
Status: Merged
Approved by: William Grant on 2012-01-25
Approved revision: no longer in the source branch.
Merged at revision: 14724
Proposed branch: lp:~stevenk/launchpad/link-bug-tags-correctly-redux
Merge into: lp:launchpad
Diff against target: 37 lines (+15/-1)
2 files modified
lib/lp/bugs/browser/bugtask.py (+1/-1)
lib/lp/bugs/browser/tests/test_bugtask.py (+14/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/link-bug-tags-correctly-redux
Reviewer Review Type Date Requested Status
William Grant code 2012-01-25 Approve on 2012-01-25
Review via email: mp+90044@code.launchpad.net

Commit Message

[r=wgrant][bug=921175] Fix the mustache model so that it quotes bug tags in the URL portion.

Description of the Change

Fix the mustache model so that it quotes bug tags in the URL portion.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtask.py'
2--- lib/lp/bugs/browser/bugtask.py 2012-01-20 05:05:40 +0000
3+++ lib/lp/bugs/browser/bugtask.py 2012-01-25 05:41:27 +0000
4@@ -2280,7 +2280,7 @@
5 'reporter': self.bug.owner.displayname,
6 'status': self.status.title,
7 'status_class': 'status' + self.status.name,
8- 'tags': [{'url': base_tag_url + tag, 'tag': tag}
9+ 'tags': [{'url': base_tag_url + urllib.quote(tag), 'tag': tag}
10 for tag in self.bug.tags],
11 'title': self.bug.title,
12 }
13
14=== modified file 'lib/lp/bugs/browser/tests/test_bugtask.py'
15--- lib/lp/bugs/browser/tests/test_bugtask.py 2012-01-20 05:05:40 +0000
16+++ lib/lp/bugs/browser/tests/test_bugtask.py 2012-01-25 05:41:27 +0000
17@@ -2282,6 +2282,20 @@
18 key[2] in ('asc', 'desc'),
19 'Invalid order value: %r' % (key, ))
20
21+ def test_tags_encoded_in_model(self):
22+ # The tag name is encoded properly in the JSON.
23+ product = self.factory.makeProduct(name='foobar')
24+ bug = self.factory.makeBug(product=product, tags=['depends-on+987'])
25+ with dynamic_listings():
26+ view = self.makeView(bugtask=bug.default_bugtask)
27+ cache = IJSONRequestCache(view.request)
28+ tags = cache.objects['mustache_model']['items'][0]['tags']
29+ expected_url = (
30+ canonical_url(product, view_name='+bugs') +
31+ '/?field.tag=depends-on%2B987')
32+ self.assertEqual(
33+ [{'url': expected_url, 'tag': u'depends-on+987'}], tags)
34+
35
36 class TestBugTaskExpirableListingView(BrowserTestCase):
37 """Test BugTaskExpirableListingView."""