Merge lp:~benji/launchpad/bug-778689 into lp:launchpad

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: no longer in the source branch.
Merged at revision: 13018
Proposed branch: lp:~benji/launchpad/bug-778689
Merge into: lp:launchpad
Diff against target: 58 lines (+30/-0)
2 files modified
lib/lp/bugs/browser/structuralsubscription.py (+5/-0)
lib/lp/registry/browser/tests/test_subscription_links.py (+25/-0)
To merge this branch: bzr merge lp:~benji/launchpad/bug-778689
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+60520@code.launchpad.net

Commit message

[r=gmb][bug=778689] make project group milestone pages not OOPS

Description of the change

This branch fixes bug 778689. There was no test coverage for a menu
mixin when viewing project group milestones and the code couldn't handle
it.

The fix was simple: since subscribing to project group milestones isn't
allowed, just disable the links.

The related tests can be run with:

    bin/test -c -m lp.registry.browser.tests.test_subscription_links

The make lint report is clean:

    = Launchpad lint =

    Checking for conflicts and issues in changed files.

    Linting changed files:
    lib/lp/bugs/browser/structuralsubscription.py
    lib/lp/registry/browser/tests/test_subscription_links.py

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

We agreed on IRC that you need to add a comment to your test so that readers don't need to luck up the bug report. Otherwise, r=me.

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/structuralsubscription.py'
2--- lib/lp/bugs/browser/structuralsubscription.py 2011-05-03 13:38:30 +0000
3+++ lib/lp/bugs/browser/structuralsubscription.py 2011-05-10 15:46:25 +0000
4@@ -381,6 +381,11 @@
5 bug subscriptions.
6 """
7 sst = self._getSST()
8+ # ProjectGroup milestones aren't really structural subscription
9+ # targets as they're not real milestones, so you can't subscribe to
10+ # them.
11+ if IProjectGroupMilestone.providedBy(sst):
12+ return False
13 pillar = IStructuralSubscriptionTargetHelper(sst).pillar
14 return (pillar.bug_tracking_usage == ServiceUsage.LAUNCHPAD and
15 sst.userCanAlterBugSubscription(self.user, self.user))
16
17=== modified file 'lib/lp/registry/browser/tests/test_subscription_links.py'
18--- lib/lp/registry/browser/tests/test_subscription_links.py 2011-04-25 18:13:31 +0000
19+++ lib/lp/registry/browser/tests/test_subscription_links.py 2011-05-10 15:46:25 +0000
20@@ -15,7 +15,11 @@
21 from canonical.launchpad.testing.pages import first_tag_by_class
22 from canonical.testing.layers import DatabaseFunctionalLayer
23
24+from lp.bugs.browser.structuralsubscription import (
25+ StructuralSubscriptionMenuMixin,
26+ )
27 from lp.registry.interfaces.person import IPersonSet
28+from lp.registry.model.milestone import ProjectMilestone
29 from lp.services.features.testing import FeatureFixture
30 from lp.testing import (
31 celebrity_logged_in,
32@@ -175,6 +179,27 @@
33 project=self.target, official_malone=True)
34
35
36+class ProjectGroupMilestone(TestCaseWithFactory):
37+ """Make sure that projects' "virtual" milestones don't break things."""
38+
39+ layer = DatabaseFunctionalLayer
40+
41+ def test_for_bug_778689(self):
42+ with person_logged_in(self.factory.makePerson()):
43+ # Project groups have "virtual" milestones that aren't stored in
44+ # the database directly (they're inherited from the contained
45+ # products). Viewing one of those group milestones would generate
46+ # an OOPS because adapting the milestone to
47+ # IStructuralSubscriptionTargetHelper would attempt to look them
48+ # up in the database, raising an exception.
49+ project = self.factory.makeProject()
50+ product = self.factory.makeProduct(project=project)
51+ mixin = StructuralSubscriptionMenuMixin()
52+ mixin.context = ProjectMilestone(project, '11.04', None, True)
53+ # Before bug 778689 was fixed, this would raise an exception.
54+ mixin._enabled
55+
56+
57 class ProjectGroupBugs(ProjectGroupView):
58 """Test structural subscriptions on the project group bugs view."""
59