Merge lp:~bac/launchpad/bug-770248 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: 12920
Proposed branch: lp:~bac/launchpad/bug-770248
Merge into: lp:launchpad
Diff against target: 139 lines (+63/-8)
4 files modified
.bzrignore (+1/-0)
lib/lp/bugs/browser/tests/test_bug_views.py (+54/-5)
lib/lp/bugs/browser/tests/test_bugsubscription_views.py (+0/-1)
lib/lp/bugs/model/bug.py (+8/-2)
To merge this branch: bzr merge lp:~bac/launchpad/bug-770248
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+59047@code.launchpad.net

Commit message

[r=gmb][bug=770248] Show mute link on a bug page if a person is in a team with a structural subscription.

Description of the change

= Summary =

If a user's team has a structural subscription to a pillar then the mute
link should be shown.

== Proposed fix ==

Fix Bug. personIsAlsoNotifiedSubscriber to take team membership into
account.

== Pre-implementation notes ==

Chat with Gary.

== Implementation details ==

As above.

== Tests ==

bin/test -vvm -t test_bug_views

== Demo and Q/A ==

Create a structural subscription on a product for a team you administer.
 Go to a bug where you have no other subscriptions. See mute link.
Dance a little jig.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/tests/test_bug_views.py
  lib/lp/bugs/model/bug.py
  lib/lp/bugs/browser/tests/test_bugsubscription_views.py

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

Hi Brad,

Just one comment:

[1]

52 + def test_bug_mute_for_individual_structural_subscription(self):

This test is missing a comment stating the expected behaviour.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2011-03-30 20:39:26 +0000
+++ .bzrignore 2011-04-26 13:02:35 +0000
@@ -81,3 +81,4 @@
81run.gdb81run.gdb
82lib/canonical/launchpad/icing/icon-sprites82lib/canonical/launchpad/icing/icon-sprites
83lib/canonical/launchpad/icing/icon-sprites.positioning83lib/canonical/launchpad/icing/icon-sprites.positioning
84.emacs.desktop
8485
=== modified file 'lib/lp/bugs/browser/tests/test_bug_views.py'
--- lib/lp/bugs/browser/tests/test_bug_views.py 2011-04-11 21:52:02 +0000
+++ lib/lp/bugs/browser/tests/test_bug_views.py 2011-04-26 13:02:35 +0000
@@ -17,7 +17,6 @@
17from lp.services.features import get_relevant_feature_controller17from lp.services.features import get_relevant_feature_controller
18from lp.testing import (18from lp.testing import (
19 BrowserTestCase,19 BrowserTestCase,
20 feature_flags,
21 person_logged_in,20 person_logged_in,
22 TestCaseWithFactory,21 TestCaseWithFactory,
23 )22 )
@@ -50,10 +49,14 @@
50class TestBugPortletSubscribers(TestCaseWithFactory):49class TestBugPortletSubscribers(TestCaseWithFactory):
5150
52 layer = DatabaseFunctionalLayer51 layer = DatabaseFunctionalLayer
52 feature_flag_1 = 'malone.advanced-subscriptions.enabled'
53 feature_flag_2 = 'malone.advanced-structural-subscriptions.enabled'
5354
54 def setUp(self):55 def setUp(self):
55 super(TestBugPortletSubscribers, self).setUp()56 super(TestBugPortletSubscribers, self).setUp()
56 self.bug = self.factory.makeBug()57 self.target = self.factory.makeProduct()
58 bug_owner = self.factory.makePerson(name="bug-owner")
59 self.bug = self.factory.makeBug(owner=bug_owner, product=self.target)
57 # We need to put the Bug and default BugTask into the LaunchBag60 # We need to put the Bug and default BugTask into the LaunchBag
58 # because BugContextMenu relies on the LaunchBag to populate its61 # because BugContextMenu relies on the LaunchBag to populate its
59 # context property62 # context property
@@ -66,7 +69,7 @@
66 # the mute link will not be displayed to them.69 # the mute link will not be displayed to them.
67 person = self.factory.makePerson()70 person = self.factory.makePerson()
68 with person_logged_in(person):71 with person_logged_in(person):
69 with feature_flags():72 with FeatureFixture({self.feature_flag_2: None}):
70 # The user isn't subscribed or muted already.73 # The user isn't subscribed or muted already.
71 self.assertFalse(self.bug.isSubscribed(person))74 self.assertFalse(self.bug.isSubscribed(person))
72 self.assertFalse(self.bug.isMuted(person))75 self.assertFalse(self.bug.isMuted(person))
@@ -82,8 +85,7 @@
82 self.assertFalse('mute_subscription' in html)85 self.assertFalse('mute_subscription' in html)
8386
84 def test_edit_subscriptions_link_shown_when_feature_enabled(self):87 def test_edit_subscriptions_link_shown_when_feature_enabled(self):
85 flag = 'malone.advanced-structural-subscriptions.enabled'88 with FeatureFixture({self.feature_flag_2: 'on'}):
86 with FeatureFixture({flag: 'on'}):
87 request = LaunchpadTestRequest()89 request = LaunchpadTestRequest()
88 request.features = get_relevant_feature_controller()90 request.features = get_relevant_feature_controller()
89 view = create_initialized_view(91 view = create_initialized_view(
@@ -98,3 +100,50 @@
98 html = view.render()100 html = view.render()
99 self.assertTrue('menu-link-editsubscriptions' not in html)101 self.assertTrue('menu-link-editsubscriptions' not in html)
100 self.assertTrue('/+subscriptions' not in html)102 self.assertTrue('/+subscriptions' not in html)
103
104 def test_bug_mute_for_individual_structural_subscription(self):
105 # If the person has a structural subscription to the pillar,
106 # then the mute link will be displayed to them.
107 person = self.factory.makePerson(name="a-person")
108 with FeatureFixture({self.feature_flag_1: 'on'}):
109 with person_logged_in(person):
110 self.target.addBugSubscription(person, person)
111 self.assertFalse(self.bug.isMuted(person))
112 view = create_initialized_view(
113 self.bug, name="+portlet-subscribers")
114 self.assertTrue(view.user_should_see_mute_link,
115 "User should see mute link.")
116 contents = view.render()
117 self.assertTrue('mute_subscription' in contents,
118 "'mute_subscription' not in contents.")
119 create_initialized_view(
120 self.bug.default_bugtask, name="+mute",
121 form={'field.actions.mute': 'Mute bug mail'})
122 self.assertTrue(self.bug.isMuted(person))
123
124 def test_mute_subscription_link_shown_for_team_subscription(self):
125 # If the person belongs to a team with a structural subscription,
126 # then the mute link will be displayed to them.
127 person = self.factory.makePerson(name="a-person")
128 team_owner = self.factory.makePerson(name="team-owner")
129 team = self.factory.makeTeam(owner=team_owner, name="subscribed-team")
130 with FeatureFixture({self.feature_flag_1: 'on'}):
131 with person_logged_in(team_owner):
132 team.addMember(person, team_owner)
133 self.target.addBugSubscription(team, team_owner)
134 with person_logged_in(person):
135 self.assertFalse(self.bug.isMuted(person))
136 self.assertTrue(
137 self.bug.personIsAlsoNotifiedSubscriber(
138 person), "Person should be a notified subscriber")
139 view = create_initialized_view(
140 self.bug, name="+portlet-subscribers")
141 self.assertTrue(view.user_should_see_mute_link,
142 "User should see mute link.")
143 contents = view.render()
144 self.assertTrue('mute_subscription' in contents,
145 "'mute_subscription' not in contents.")
146 create_initialized_view(
147 self.bug.default_bugtask, name="+mute",
148 form={'field.actions.mute': 'Mute bug mail'})
149 self.assertTrue(self.bug.isMuted(person))
101150
=== modified file 'lib/lp/bugs/browser/tests/test_bugsubscription_views.py'
--- lib/lp/bugs/browser/tests/test_bugsubscription_views.py 2011-04-21 18:29:18 +0000
+++ lib/lp/bugs/browser/tests/test_bugsubscription_views.py 2011-04-26 13:02:35 +0000
@@ -36,7 +36,6 @@
36 super(BugSubscriptionAdvancedFeaturesTestCase, self).setUp()36 super(BugSubscriptionAdvancedFeaturesTestCase, self).setUp()
37 self.bug = self.factory.makeBug()37 self.bug = self.factory.makeBug()
38 self.person = self.factory.makePerson()38 self.person = self.factory.makePerson()
39 self.team = self.factory.makeTeam()
4039
41 def test_subscribe_uses_bug_notification_level(self):40 def test_subscribe_uses_bug_notification_level(self):
42 # When a user subscribes to a bug using the advanced features on41 # When a user subscribes to a bug using the advanced features on
4342
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py 2011-04-19 18:30:12 +0000
+++ lib/lp/bugs/model/bug.py 2011-04-26 13:02:35 +0000
@@ -1894,8 +1894,14 @@
1894 # and assignees. As such, it's not possible to get them all with1894 # and assignees. As such, it's not possible to get them all with
1895 # one query.1895 # one query.
1896 also_notified_subscribers = self.getAlsoNotifiedSubscribers()1896 also_notified_subscribers = self.getAlsoNotifiedSubscribers()
18971897 if person in also_notified_subscribers:
1898 return person in also_notified_subscribers1898 return True
1899 # Otherwise check to see if the person is a member of any of the
1900 # subscribed teams.
1901 for subscriber in also_notified_subscribers:
1902 if subscriber.is_team and person.inTeam(subscriber):
1903 return True
1904 return False
18991905
1900 def personIsSubscribedToDuplicate(self, person):1906 def personIsSubscribedToDuplicate(self, person):
1901 """See `IBug`."""1907 """See `IBug`."""