Merge lp:~gmb/launchpad/fix-advanced-bug-sub-ui-bug-673288 into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Gavin Panella on 2010-11-12 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11924 |
| Proposed branch: | lp:~gmb/launchpad/fix-advanced-bug-sub-ui-bug-673288 |
| Merge into: | lp:launchpad |
| Diff against target: |
164 lines (+112/-7) 2 files modified
lib/lp/bugs/browser/bugsubscription.py (+33/-7) lib/lp/bugs/browser/tests/test_bugsubscription_views.py (+79/-0) |
| To merge this branch: | bzr merge lp:~gmb/launchpad/fix-advanced-bug-sub-ui-bug-673288 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Gavin Panella (community) | 2010-11-11 | Approve on 2010-11-12 | |
|
Review via email:
|
|||
Commit Message
[r=allenap]
Description of the Change
This branch fixes bug 673288 by making the "Update my subscription"
option on the +subscribe page disappear if the user is not directly
subscribed to the bug.
I've also made the bug_notificatio
isn't directly subscribed, since having it there makes no sense.
== lib/lp/
- I've made the changes necessary to fix bug 673288.
== lib/lp/
- I've added a regresession test for the bug as well as two other tests
to ensure proper behaviour of the view.
| Graham Binns (gmb) wrote : | # |
| Gavin Panella (allenap) wrote : | # |
Looks good, but I have a suggestion about making the code a little
clearer and I have some concerns about the tests.
[1]
+ if (self._
+ self.current_
...
+ if (self._
+ self.current_
...
+ if (self.user_
+ self.current_
user_is_subscribed is defined as:
@cachedproperty
def user_is_
"""Is the user subscribed to this bug?"""
return (
I think it would probably be easier to understand some of this logic
if this were split up:
@cachedproperty
def user_is_
"""Is the user subscribed directly to this bug?"""
return self.context.
@cachedproperty
def user_is_
"""Is the user subscribed to dupes of this bug?"""
return self.context.
def user_is_
"""Is the user subscribed to this bug?"""
return (self.user_
def user_is_
"""Is the user subscribed to this bug only via a dupe?"""
return (self.user_
not self.user_
Then the three examples become:
if (self._
...
if (self._
...
if (self.user_
I know it's more typing - hehe, done for you :) - but it reads
better. This view is complicated and difficult to follow, so I think
it could do with some help in this regard.
[2]
+ def test_update_
+ def test_update_
+ def test_bug_
The tests are fine, but I wonder if they're the right way to test
this bug.
From reading the bug, it seems that the view was already doing
something like the right thing: it was breaking when presented with a
nonsensical request. The real bug, as far as I can tell, is that the
form presented to the user is wrong.
I think the tests should be demonstrating what fields the view expects
in the various scenarios. I don't think it's even necessary to submit
forms to the view.
| Graham Binns (gmb) wrote : | # |
Hi Gavin,
On Thu, Nov 11, 2010 at 04:32:54PM -0000, Gavin Panella wrote:
> Review: Needs Fixing
> Looks good, but I have a suggestion about making the code a little
> clearer and I have some concerns about the tests.
Cool, thanks.
> [1]
>[...]
> I know it's more typing - hehe, done for you :) - but it reads
> better. This view is complicated and difficult to follow, so I think
> it could do with some help in this regard.
I agree. I've done as you suggested (thanks for doing the work for me
;)).
> [2]
>
> + def test_update_
> + def test_update_
> + def test_bug_
>
> The tests are fine, but I wonder if they're the right way to test
> this bug.
>
> >From reading the bug, it seems that the view was already doing
> something like the right thing: it was breaking when presented with a
> nonsensical request. The real bug, as far as I can tell, is that the
> form presented to the user is wrong.
>
> I think the tests should be demonstrating what fields the view expects
> in the various scenarios. I don't think it's even necessary to submit
> forms to the view.
>
Hmm. I see your point. I've updated the tests as you suggest (and in the
process discovered how to test the options in the fields, which is
cool).

Here's a conflict-free diff.
=== modified file 'lib/lp/ bugs/browser/ bugsubscription .py' bugs/browser/ bugsubscription .py 2010-11-09 19:41:24 +0000 bugs/browser/ bugsubscription .py 2010-11-11 14:46:00 +0000
self_ subscribed = False rs_for_ current_ user: advanced_ features: use_advanced_ features and user_subscripti on is not None):
subscription_ terms.append( self._update_ subscription_ term) terms.append( terms.insert(
person, person.name,
'Unsubscrib e me from this bug'))
self_ subscribed = True
SimpleTerm(
self.user, self.user.name, 'Subscribe me to this bug'))
subscription_ vocabulary = SimpleVocabular y(subscription_ terms) is_subscribed and self._use_ advanced_ features: use_advanced_ features and user_subscripti on is not None):
default_ subscription_ value = self._update_ subscription_ term.value
default_ subscription_ value = (
self. widgets[ 'subscription' ].visible = True
--- lib/lp/
+++ lib/lp/
@@ -225,10 +225,11 @@
for person in self._subscribe
if person.id == self.user.id:
- if self._use_
+ if (self._
+ self.current_
- subscription_
- SimpleTerm(
+ subscription_
+ 0, SimpleTerm(
@@ -244,7 +245,8 @@
- if self.user_
+ if (self._
+ self.current_
else:
@@ -284,6 +286,13 @@
# subscribe theirself or unsubscribe their team.
+ if (self.user_ is_subscribed and user_subscripti on is None): n_level field, since it's not used. 'bug_notificati on_level' ].visible = False perty subscribed( self):
+ self.current_
+ # If the user is subscribed via a duplicate but is not
+ # directly subscribed, we hide the
+ # bug_notificatio
+ self.widgets[
+
@cachedpro
def user_is_
"""Is the user subscribed to this bug?"""
=== modified file 'lib/lp/ bugs/browser/ tests/test_ bugsubscription _views. py' bugs/browser/ tests/test_ bugsubscription _views. py 2010-11-11 10:37:48 +0000 bugs/browser/ tests/test_ bugsubscription _views. py 2010-11-11 14:46:42 +0000
--- lib/lp/
+++ lib/lp/
@@ -10,6 +10,7 @@
from lp.bugs. browser. bugsubscription import ( SubcribersIds, AddView, ptionSubscribeS elfView, Level
"METADATA, is actually %s"
% default_ notification_ level_value)
BugPortlet
+ BugSubscription
BugSubscri
)
from lp.registry.enum import BugNotification
@@ -170,6 +171,99 @@
+ def test_update_ subscription_ fails_if_ user_not_ subscribed( self): makeBug( ) makePerson( ) logged_ in(person) : Level.METADATA rness(
+ # If the user is not directly subscribed to the bug, trying to
+ # update the subscription will fail (since you can't update a
+ # subscription that doesn't exist).
+ bug = self.factory.
+ person = self.factory.
+ with feature_flags():
+ with person_
+ level = BugNotification
+ harness = LaunchpadFormHa
+ ...