Merge lp:~sinzui/launchpad/unicode-project-group-bug into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Richard Harding
Approved revision: no longer in the source branch.
Merged at revision: 16264
Proposed branch: lp:~sinzui/launchpad/unicode-project-group-bug
Merge into: lp:launchpad
Diff against target: 120 lines (+54/-7)
3 files modified
lib/lp/bugs/browser/bugtarget.py (+4/-2)
lib/lp/bugs/browser/tests/test_bugtarget_filebug.py (+45/-0)
lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt (+5/-5)
To merge this branch: bzr merge lp:~sinzui/launchpad/unicode-project-group-bug
Reviewer Review Type Date Requested Status
Richard Harding (community) Approve
Review via email: mp+134154@code.launchpad.net

Commit message

Reporting a bug from a project group accepts unicode bug summaries

Description of the change

The report a bug from a project group form fails if the summary
contains unicode. form forwards the request to the selected project,
but the summary is assumed to be ascii. The call to URLEncode fails
when give unicode.

--------------------------------------------------------------------

RULES

    Pre-implementation: no one
    * ProjectGroupFileBugGuidedView.projectgroup_search_action needs
      to decode the summary before passing it to URLEncode.

    ADDENDUM:
    * The redirect does not go to the bug domain. It should.

QA

    * Visit https://bugs.qastaging.launchpad.net/ubuntu-fr-website-project/+filebug
    * Choose Forum Ubuntu-fr
    * Enter "Le bouton liste à puces n'est pas correct" in the summary field.
    * Choose Continue
    * Verify the page redirect to the Forum Ubuntu-fr project and
      shows the matches and/or bug form.
    * Verify the url using the bugs host.

LINT

    lib/lp/bugs/browser/bugtarget.py
    lib/lp/bugs/browser/tests/test_bugtarget_filebug.py

LoC

    I have a 3000 line credit this week.

TEST

    ./bin/test -vvc -t ProjectGroup lp.bugs.browser.tests.test_bugtarget_filebug

IMPLEMENTATION

I discovered that the redirect url went to the wrong host when I was
investigating a fix. I added the missing rootsite arg and test for it.
I expected the test to verify that the summary is encoded as utf8 before
passing it to URLEncode(). Note that will bug tags have to be unicode in
tests, the validator requires that they are ascii; it is not possibly
to have a similar problem with bug tags.
    lib/lp/bugs/browser/bugtarget.py
    lib/lp/bugs/browser/tests/test_bugtarget_filebug.py

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtarget.py'
2--- lib/lp/bugs/browser/bugtarget.py 2012-11-06 05:56:49 +0000
3+++ lib/lp/bugs/browser/bugtarget.py 2012-11-13 17:58:22 +0000
4@@ -1081,10 +1081,12 @@
5 @action("Continue", name="projectgroupsearch")
6 def projectgroup_search_action(self, action, data):
7 """Redirect to the chosen product's form."""
8- base = canonical_url(data['product'], view_name='+filebug')
9+ base = canonical_url(
10+ data['product'], view_name='+filebug', rootsite='bugs')
11+ title = data['title'].encode('utf8')
12 query = urllib.urlencode([
13 ('field.actions.search', 'Continue'),
14- ('field.title', data['title']),
15+ ('field.title', title),
16 ('field.tags', ' '.join(data['tags'])),
17 ])
18 url = '%s?%s' % (base, query)
19
20=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_filebug.py'
21--- lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-11-06 04:34:48 +0000
22+++ lib/lp/bugs/browser/tests/test_bugtarget_filebug.py 2012-11-13 17:58:22 +0000
23@@ -813,6 +813,51 @@
24 self.assertIn("Thank you for your bug report.", msg)
25
26
27+class ProjectGroupFileBugGuidedViewTestCase(TestCaseWithFactory):
28+
29+ layer = DatabaseFunctionalLayer
30+
31+ def makeProjectGroupFileBugView(self, product_name, bug_title, tags=''):
32+ project_group = self.factory.makeProject()
33+ owner = project_group.owner
34+ product = self.factory.makeProduct(
35+ owner=owner, name=product_name, project=project_group)
36+ with person_logged_in(owner):
37+ product.official_malone = True
38+ form = {
39+ 'field.product': product_name,
40+ 'field.title': bug_title,
41+ 'field.tags': tags,
42+ 'field.actions.projectgroupsearch': 'Continue',
43+ }
44+ view = create_initialized_view(
45+ project_group, name='+filebug', form=form, rootsite='bugs')
46+ return view
47+
48+ def test_redirect_to_project(self):
49+ # The view redirects to the select sub project.
50+ view = self.makeProjectGroupFileBugView('fnord', 'A bug', u'is os')
51+ response = view.request.response
52+ self.assertEqual(302, response.getStatus())
53+ self.assertEqual(
54+ 'http://bugs.launchpad.dev/fnord/+filebug?'
55+ 'field.actions.search=Continue&'
56+ 'field.title=A+bug&'
57+ 'field.tags=is+os',
58+ response.getHeader('Location'))
59+
60+ def test_redirect_to_project_unicode_summary(self):
61+ # The summary is reencoded properly when it contains unicode.
62+ view = self.makeProjectGroupFileBugView('fnord', u'caf\xe9', '')
63+ response = view.request.response
64+ self.assertEqual(
65+ 'http://bugs.launchpad.dev/fnord/+filebug?'
66+ 'field.actions.search=Continue&'
67+ 'field.title=caf%C3%A9&'
68+ 'field.tags=',
69+ response.getHeader('Location'))
70+
71+
72 class TestFileBugRequestCache(TestCaseWithFactory):
73 # Tests to ensure the request cache contains the expected values for
74 # file bug views.
75
76=== modified file 'lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt'
77--- lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt 2012-08-03 00:18:27 +0000
78+++ lib/lp/bugs/stories/guided-filebug/xx-bug-reporting-guidelines.txt 2012-11-13 17:58:22 +0000
79@@ -66,7 +66,7 @@
80
81 >>> for context_name, context_path, view in contexts:
82 ... filebug_url = (
83- ... 'http://launchpad.dev/%s/+filebug' % (context_path,))
84+ ... 'http://bugs.launchpad.dev/%s/+filebug' % (context_path,))
85 ... user_browser.open(filebug_url)
86 ... user_browser.getControl('Summary', index=0).value = (
87 ... "It doesn't work")
88@@ -78,28 +78,28 @@
89 ... print_acknowledgement_message(user_browser)
90 *
91 Ubuntu
92- <http://launchpad.dev/ubuntu/+filebug>
93+ <http://bugs.launchpad.dev/ubuntu/+filebug>
94 Ubuntu bug reporting guidelines:
95 The version of Ubuntu you're using.
96 See http://example.com for more details.
97 Thank you for filing a bug for https://launchpad.dev/ubuntu
98 *
99 Mozilla
100- <http://launchpad.dev/firefox/+filebug?field.actions.search=Continue&field.title=It+doesn%27t+work&field.tags=>
101+ <http://bugs.launchpad.dev/firefox/+filebug?field.actions.search=Continue&field.title=It+doesn%27t+work&field.tags=>
102 Mozilla Firefox bug reporting guidelines:
103 The version of Firefox you're using.
104 See http://example.com for more details.
105 Thank you for filing a bug for https://launchpad.dev/firefox
106 *
107 Firefox
108- <http://launchpad.dev/firefox/+filebug>
109+ <http://bugs.launchpad.dev/firefox/+filebug>
110 Mozilla Firefox bug reporting guidelines:
111 The version of Firefox you're using.
112 See http://example.com for more details.
113 Thank you for filing a bug for https://launchpad.dev/firefox
114 *
115 alsa-utils in Ubuntu
116- <http://launchpad.dev/ubuntu/+source/alsa-utils/+filebug>
117+ <http://bugs.launchpad.dev/ubuntu/+source/alsa-utils/+filebug>
118 alsa-utils (Ubuntu) bug reporting guidelines:
119 The version of alsa-utils in Ubuntu you're using.
120 See http://example.com for more details.