← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/do-not-validate-bugwatch-on-delete into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/do-not-validate-bugwatch-on-delete into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1079523 in Launchpad itself: "Deleting a bug watch calls validation"
  https://bugs.launchpad.net/launchpad/+bug/1079523

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/do-not-validate-bugwatch-on-delete/+merge/191543

Call a no-op validator when deleting a bug watch. We are about to drop the data from the database, so there is no point in checking that the data is valid.
-- 
https://code.launchpad.net/~stevenk/launchpad/do-not-validate-bugwatch-on-delete/+merge/191543
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/do-not-validate-bugwatch-on-delete into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugwatch.py'
--- lib/lp/bugs/browser/bugwatch.py	2012-11-26 08:40:20 +0000
+++ lib/lp/bugs/browser/bugwatch.py	2013-10-17 01:02:30 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """IBugWatch-related browser views."""
@@ -135,7 +135,8 @@
             len(self.context.bugtasks) == 0 and
             self.context.getBugMessages().is_empty())
 
-    @action('Delete Bug Watch', name='delete', condition=bugWatchIsUnlinked)
+    @action('Delete Bug Watch', name='delete', condition=bugWatchIsUnlinked,
+            validator='validate_cancel')
     def delete_action(self, action, data):
         bugwatch = self.context
         # Build the notification first, whilst we still have the data.

=== modified file 'lib/lp/bugs/browser/tests/test_bugwatch_views.py'
--- lib/lp/bugs/browser/tests/test_bugwatch_views.py	2013-05-09 08:53:01 +0000
+++ lib/lp/bugs/browser/tests/test_bugwatch_views.py	2013-10-17 01:02:30 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2013 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for BugWatch views."""
@@ -45,6 +45,16 @@
         self.assertContentEqual([], view.errors)
         self.assertRaises(NotFoundError, getUtility(IBugWatchSet).get, bwid)
 
+    def test_can_delete_watch_with_invalid_url(self):
+        bwid = self.bug_watch.id
+        form = {
+            'field.url': 'foobarbaz',
+            'field.actions.delete': 'Delete Bug Watch'}
+        getUtility(ILaunchBag).add(self.bug_task.bug)
+        view = create_initialized_view(self.bug_watch, '+edit', form=form)
+        self.assertContentEqual([], view.errors)
+        self.assertRaises(NotFoundError, getUtility(IBugWatchSet).get, bwid)
+
     def test_can_not_delete_unlinked_watch_with_unsynched_comments(self):
         # If a bugwatch is unlinked, but has imported comments that are
         # awaiting synch, it can not be deleted.


Follow ups