Merge lp:~abentley/launchpad/distro-structural-subscription into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 14497
Proposed branch: lp:~abentley/launchpad/distro-structural-subscription
Merge into: lp:launchpad
Diff against target: 70 lines (+16/-11)
2 files modified
lib/lp/registry/javascript/structural-subscription.js (+7/-3)
lib/lp/registry/javascript/tests/test_structural_subscription.js (+9/-8)
To merge this branch: bzr merge lp:~abentley/launchpad/distro-structural-subscription
Reviewer Review Type Date Requested Status
Deryck Hodge (community) Approve
Review via email: mp+85356@code.launchpad.net

Commit message

No exception when structural subscriptions disabled.

Description of the change

= Summary =
Fix bug #902252: sort buttons that are missing on the distribution dynamic bugs listing

== Proposed fix ==
Change the structural subscription code so that it does not raise an exception if there is no structural subscription link. There are cases, specifically related to distros, where it is reasonable for the link to be missing, even if a user is logged in.

== Pre-implementation notes ==
Discussed with bac

== Implementation details ==
Changed Y.error to Y.log and updated the tests accordingly.

Fixed some lint.

== Tests ==
xvfb-run bin/test -t test_structural_subscription.html

== Demo and Q/A ==
Ensure you are member of custom-buglisting-demo and not a member of charm-contributors on qastaging. Go to https://bugs.qastaging.launchpad.net/charm

The order-by bar should be present, the next link should be green, and there should be no "Subscribe to bug mail" link.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/javascript/tests/test_structural_subscription.js
  lib/lp/registry/javascript/structural-subscription.js

To post a comment you must log in.
Revision history for this message
Deryck Hodge (deryck) wrote :

The code looks great and the change is minimal, so r=me. As we discussed on IRC, we should try to avoid log output for pages when the behavior is normal and not exceptional, but I take the point that this helps people debug what's happening here. I'm fine for it to stand if we log at a lower priority, i.e. to debug. We can turn it on if we need, but it's not noising on normal page requests.

Thanks for being flexible and being willing to fix this up. Approved with that change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/javascript/structural-subscription.js'
2--- lib/lp/registry/javascript/structural-subscription.js 2011-11-26 04:03:29 +0000
3+++ lib/lp/registry/javascript/structural-subscription.js 2011-12-12 16:51:25 +0000
4@@ -575,7 +575,9 @@
5 .set('size', '50'))
6 .append(Y.Node.create('<a/>')
7 .set('target', 'help')
8- .set('href', '/+help-registry/structural-subscription-tags.html')
9+ .set(
10+ 'href', '/+help-registry/structural-subscription-tags'
11+ + '.html')
12 .addClass('sprite')
13 .addClass('maybe')
14 .append(Y.Node.create('<span/>')
15@@ -779,7 +781,8 @@
16 ' <dd>' +
17 ' <input type="text" name="name">' +
18 ' <a target="help" class="sprite maybe"' +
19- ' href="/+help-registry/structural-subscription-name.html">&nbsp;' +
20+ ' href="/+help-registry/structural-subscription-name' +
21+ '.html">&nbsp;' +
22 ' <span class="invisible-link">Structural subscription' +
23 ' description help</span></a> ' +
24 ' </dd>' +
25@@ -1836,7 +1839,8 @@
26 // Modify the menu-link-subscribe-to-bug-mail link to be visible.
27 var link = Y.one(link_id);
28 if (!Y.Lang.isValue(link)) {
29- Y.error('Link to set as the pop-up link not found.');
30+ Y.log('No structural subscription link found.', 'debug');
31+ return;
32 }
33 link.removeClass('invisible-link');
34 link.addClass('visible-link');
35
36=== modified file 'lib/lp/registry/javascript/tests/test_structural_subscription.js'
37--- lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-07-08 05:12:39 +0000
38+++ lib/lp/registry/javascript/tests/test_structural_subscription.js 2011-12-12 16:51:25 +0000
39@@ -1472,16 +1472,17 @@
40 delete this.content_box;
41 },
42
43- _should: {
44- error: {
45- test_setup_subscription_link_none: new Error(
46- 'Link to set as the pop-up link not found.')
47- }
48- },
49-
50 // Setting up a subscription link with no link in the DOM should fail.
51 test_setup_subscription_link_none: function() {
52+ var logged_missing_link = false;
53+ Y.on('yui:log', function(e){
54+ if (e.msg === "No structural subscription link found."){
55+ logged_missing_link = true;
56+ }
57+ });
58 module.setup_subscription_link(this.config, "#link");
59+ Y.Assert.isTrue(
60+ logged_missing_link, "Missing link not reported.");
61 },
62
63 // Setting up a subscription link should unset the 'invisible-link',
64@@ -1849,5 +1850,5 @@
65 }));
66
67 Y.lp.testing.Runner.run(suite);
68-
69+
70 });