Merge ~cjwatson/launchpad:fix-packagename-option into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 727ca6d696a3e74dbda0f60f6657be53f751350c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-packagename-option
Merge into: launchpad:master
Diff against target: 69 lines (+31/-2)
2 files modified
lib/lp/bugs/browser/bugtarget.py (+3/-1)
lib/lp/bugs/browser/tests/test_bugtarget_filebug.py (+28/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+374086@code.launchpad.net

Commit message

Fix handling of packagename_option on DSP:+filebug

If "In what package did you find this bug?" is set to "I don't know" on
DistributionSourcePackage:+filebug, then it's most coherent to treat
that as if the bug had been filed using the corresponding
Distribution:+filebug.

LP: #1847647

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/bugs/browser/bugtarget.py b/lib/lp/bugs/browser/bugtarget.py
2index 5915a66..82d49db 100644
3--- a/lib/lp/bugs/browser/bugtarget.py
4+++ b/lib/lp/bugs/browser/bugtarget.py
5@@ -1,4 +1,4 @@
6-# Copyright 2010-2018 Canonical Ltd. This software is licensed under the
7+# Copyright 2010-2019 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9
10 """IBugTarget-related browser views."""
11@@ -528,6 +528,8 @@ class FileBugViewBase(LaunchpadFormView):
12 # enters a package name but then selects "I don't know".
13 if self.request.form.get("packagename_option") == "none":
14 packagename = None
15+ if IDistributionSourcePackage.providedBy(context):
16+ context = context.distribution
17
18 linkified_ack = structured(FormattersAPI(
19 self.getAcknowledgementMessage(self.context)).text_to_html(
20diff --git a/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py b/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
21index f6c53ec..3c7946e 100644
22--- a/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
23+++ b/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
24@@ -1,4 +1,4 @@
25-# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
26+# Copyright 2010-2019 Canonical Ltd. This software is licensed under the
27 # GNU Affero General Public License version 3 (see the file LICENSE).
28
29 __metaclass__ = type
30@@ -57,6 +57,7 @@ from lp.testing.pages import (
31 find_main_content,
32 find_tag_by_id,
33 )
34+from lp.testing.publication import test_traverse
35 from lp.testing.views import (
36 create_initialized_view,
37 create_view,
38@@ -833,6 +834,32 @@ class TestFileBugSourcePackage(WithScenarios, TestCaseWithFactory):
39 for notification in view.request.response.notifications])
40 self.assertIn("Thank you for your bug report.", msg)
41
42+ def test_filebug_packagename_option_none(self):
43+ # Setting "In what package did you find this bug?" to "I don't know"
44+ # is honoured even if the context is a DistributionSourcePackage.
45+ dsp = self.factory.makeDistributionSourcePackage()
46+ user = self.factory.makePerson()
47+ login_person(user)
48+
49+ view = create_initialized_view(
50+ context=dsp, name='+filebug',
51+ form={
52+ 'field.title': 'A bug',
53+ 'field.comment': 'A comment',
54+ 'packagename_option': 'none',
55+ 'field.packagename': dsp.name,
56+ 'field.actions.submit_bug': 'Submit Bug Report',
57+ }, principal=user)
58+ msg = "\n".join([
59+ notification.message
60+ for notification in view.request.response.notifications])
61+ self.assertIn("Thank you for your bug report.", msg)
62+
63+ login_person(user)
64+ bugtask, _, _ = test_traverse(
65+ view.request.response.getHeader('Location'))
66+ self.assertEqual(dsp.distribution, bugtask.target)
67+
68
69 class ProjectGroupFileBugGuidedViewTestCase(TestCaseWithFactory):
70

Subscribers

People subscribed via source and target branches

to status/vote changes: