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
diff --git a/lib/lp/bugs/browser/bugtarget.py b/lib/lp/bugs/browser/bugtarget.py
index 5915a66..82d49db 100644
--- a/lib/lp/bugs/browser/bugtarget.py
+++ b/lib/lp/bugs/browser/bugtarget.py
@@ -1,4 +1,4 @@
1# Copyright 2010-2018 Canonical Ltd. This software is licensed under the1# Copyright 2010-2019 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""IBugTarget-related browser views."""4"""IBugTarget-related browser views."""
@@ -528,6 +528,8 @@ class FileBugViewBase(LaunchpadFormView):
528 # enters a package name but then selects "I don't know".528 # enters a package name but then selects "I don't know".
529 if self.request.form.get("packagename_option") == "none":529 if self.request.form.get("packagename_option") == "none":
530 packagename = None530 packagename = None
531 if IDistributionSourcePackage.providedBy(context):
532 context = context.distribution
531533
532 linkified_ack = structured(FormattersAPI(534 linkified_ack = structured(FormattersAPI(
533 self.getAcknowledgementMessage(self.context)).text_to_html(535 self.getAcknowledgementMessage(self.context)).text_to_html(
diff --git a/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py b/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
index f6c53ec..3c7946e 100644
--- a/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
+++ b/lib/lp/bugs/browser/tests/test_bugtarget_filebug.py
@@ -1,4 +1,4 @@
1# Copyright 2010-2016 Canonical Ltd. This software is licensed under the1# Copyright 2010-2019 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -57,6 +57,7 @@ from lp.testing.pages import (
57 find_main_content,57 find_main_content,
58 find_tag_by_id,58 find_tag_by_id,
59 )59 )
60from lp.testing.publication import test_traverse
60from lp.testing.views import (61from lp.testing.views import (
61 create_initialized_view,62 create_initialized_view,
62 create_view,63 create_view,
@@ -833,6 +834,32 @@ class TestFileBugSourcePackage(WithScenarios, TestCaseWithFactory):
833 for notification in view.request.response.notifications])834 for notification in view.request.response.notifications])
834 self.assertIn("Thank you for your bug report.", msg)835 self.assertIn("Thank you for your bug report.", msg)
835836
837 def test_filebug_packagename_option_none(self):
838 # Setting "In what package did you find this bug?" to "I don't know"
839 # is honoured even if the context is a DistributionSourcePackage.
840 dsp = self.factory.makeDistributionSourcePackage()
841 user = self.factory.makePerson()
842 login_person(user)
843
844 view = create_initialized_view(
845 context=dsp, name='+filebug',
846 form={
847 'field.title': 'A bug',
848 'field.comment': 'A comment',
849 'packagename_option': 'none',
850 'field.packagename': dsp.name,
851 'field.actions.submit_bug': 'Submit Bug Report',
852 }, principal=user)
853 msg = "\n".join([
854 notification.message
855 for notification in view.request.response.notifications])
856 self.assertIn("Thank you for your bug report.", msg)
857
858 login_person(user)
859 bugtask, _, _ = test_traverse(
860 view.request.response.getHeader('Location'))
861 self.assertEqual(dsp.distribution, bugtask.target)
862
836863
837class ProjectGroupFileBugGuidedViewTestCase(TestCaseWithFactory):864class ProjectGroupFileBugGuidedViewTestCase(TestCaseWithFactory):
838865

Subscribers

People subscribed via source and target branches

to status/vote changes: