← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/double-unmute-oops into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/double-unmute-oops into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #899124 in Launchpad itself: "ClassInfoError: <type 'NoneType'>.__storm_table__ missing unmuting a bug"
  https://bugs.launchpad.net/launchpad/+bug/899124

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/double-unmute-oops/+merge/119663

IBug.mute() will deal if the bug is already muted, but IBug.unmute() will not deal if the bug is already unmuted. Add a test case, and fix it.
-- 
https://code.launchpad.net/~stevenk/launchpad/double-unmute-oops/+merge/119663
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/double-unmute-oops into lp:launchpad.
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py	2012-08-08 05:17:15 +0000
+++ lib/lp/bugs/model/bug.py	2012-08-15 02:40:27 +0000
@@ -929,7 +929,8 @@
             # This may be a webservice request.
             person = unmuted_by
         mutes = self._getMutes(person)
-        store.remove(mutes.one())
+        if not mutes.is_empty():
+            store.remove(mutes.one())
         return self.getSubscriptionForPerson(person)
 
     @property

=== modified file 'lib/lp/bugs/tests/test_bug.py'
--- lib/lp/bugs/tests/test_bug.py	2012-08-08 05:22:14 +0000
+++ lib/lp/bugs/tests/test_bug.py	2012-08-15 02:40:27 +0000
@@ -131,6 +131,14 @@
             self.bug.unmute(None, self.person)
             self.assertFalse(self.bug.isMuted(self.person))
 
+    def test_double_unmute(self):
+        # If unmute is called when not muted, it is a no-op.
+        with person_logged_in(self.person):
+            self.bug.mute(self.person, self.person)
+            subscriptions = self.bug.unmute(self.person, self.person)
+            sec_subscriptions = self.bug.unmute(self.person, self.person)
+            self.assertEqual(sec_subscriptions, subscriptions)
+
 
 class TestBugSnapshotting(TestCaseWithFactory):
     layer = DatabaseFunctionalLayer


Follow ups