Merge lp:~dev-nigelj/launchpad/bug837290 into lp:launchpad

Proposed by Nigel Jones
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 13839
Proposed branch: lp:~dev-nigelj/launchpad/bug837290
Merge into: lp:launchpad
Diff against target: 72 lines (+51/-0)
2 files modified
lib/lp/app/javascript/subscribers/subscribers_list.js (+1/-0)
lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js (+50/-0)
To merge this branch: bzr merge lp:~dev-nigelj/launchpad/bug837290
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+73369@code.launchpad.net

Commit message

[r=gmb][bug=837290] SubscribersList() now handles default configuration options properly so as to prevent objects from being undefined.

Description of the change

Summary

Bug 837290 is an edge case, where if the only subscriber to a bug is logged-in and viewing the bug, the message 'No other undefined' appears instead of 'No other subscribers'. Further testing showed this was also the case for the answer tracker system.

Proposed Fix

The issue appears to be that within lib/lp/app/javascript/subscribers/subscribers_list.js SubscribersLoader receives a set of configuration variables (property name 'config') and then merges them with default variables (at the top of the file). However the fully merged variables aren't passed to SubscribersList() which is passed config.

My proposed fix is to merge 'config' with the defaults, to both 'this' and 'config' so that if not specified by callers (both bugs & answers don't pass all details and merging is required) of SubscribersLoader() then correct defaults will be passed to SubscribersList() and the sub-function that produces the 'No other subscribers' message.

Pre-implementation notes

I discussed the issue with Graham (gmb) on #launchpad-dev who agreed on IRC that it seems that this way is likely the best way to go.

Implementation details

I implemented the Proposed Fix to lib/lp/app/javascript/subscribers/subscribers_list.js and verified that the correct message was displayed.

Tests

I have repeated two unit tests to run from within SubscribersLoader() (instead of SubscribersList()) to test that configuration merging works as intended.

Testing against the devel branch, the two tests failed, against my patch, the all tests passed.

Demo & Q/A

On a clean Launchpad setup, I logged in with the default <email address hidden>/test user/pass combination created a new project, configured the bug tracker and created a bug against the new project.

Once the bug is created, the right sidebar displays "No other subscribers" on an un-patched Launchpad, this will say "No other undefined"

Lint

njones:~/launchpad/lp-branches/bug-837290$ make lint
bzr: ERROR: unknown command "pipes"
= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/app/javascript/subscribers/subscribers_list.js
  lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js

(Not sure why 'bzr pipes' is missing but other than that, looks clean)

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

Hi Nigel,

Nice branch, thanks for doing the hard work! I'm happy for this to land and will run it through EC2 for you shortly.

review: Approve (code)
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Nigel signed the contributor agreement so gmb feel free to land this branch.

Revision history for this message
Graham Binns (gmb) wrote :

This branch is now playing in EC2. I'll let you know how it fares.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
2--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-15 03:42:02 +0000
3+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-30 13:08:25 +0000
4@@ -79,6 +79,7 @@
5 this[config_var] = config[config_var];
6 } else {
7 this[config_var] = CONFIG_DEFAULTS[config_var];
8+ config[config_var] = CONFIG_DEFAULTS[config_var];
9 }
10 }
11 }
12
13=== modified file 'lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js'
14--- lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-15 03:42:02 +0000
15+++ lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-30 13:08:25 +0000
16@@ -2734,6 +2734,56 @@
17 }
18 }));
19
20+/**
21+ * Re-test several resetNoSubscribers() tests that need config options merging
22+ * (LP Bug 837290)
23+ */
24+suite.add(new Y.Test.Case({
25+ name: 'SubscribersLoader.SubscribersList.resetNoSubscribers() re-test',
26+
27+ setUp: function() {
28+ this.root = Y.Node.create('<div />');
29+ Y.one('body').appendChild(this.root);
30+ },
31+
32+ tearDown: function() {
33+ this.root.remove();
34+ },
35+
36+ test_no_subscribers: function() {
37+ // When resetNoSubscribers() is called on an empty
38+ // SubscribersList, indication of no subscribers is added.
39+ // In addition, this checks that the default configuration options
40+ // have been correctly merged without SubscribersLoader()
41+ var loader = setUpLoader(this.root);
42+ var subscribers_list = loader.subscribers_list;
43+ subscribers_list.resetNoSubscribers();
44+ var no_subs_nodes = this.root.all(
45+ '.no-subscribers-indicator');
46+ Y.Assert.areEqual(1, no_subs_nodes.size());
47+ Y.Assert.areEqual('No other subscribers.',
48+ no_subs_nodes.item(0).get('text'));
49+ },
50+
51+ test_no_subscribers_no_levels: function() {
52+ // When resetNoSubscribers() is called on an empty
53+ // SubscribersList, indication of no subscribers is added. If there
54+ // are no subscriber_levels, a different message is displayed.
55+ // In addition, this checks that the default configuration options
56+ // have been correctly merged without SubscribersLoader()
57+ var loader = setUpLoader(this.root);
58+ var subscribers_list = loader.subscribers_list;
59+ subscribers_list.subscriber_levels = [];
60+ subscribers_list.resetNoSubscribers();
61+ var no_subs_nodes = this.root.all(
62+ '.no-subscribers-indicator');
63+ Y.Assert.areEqual(1, no_subs_nodes.size());
64+ Y.Assert.areEqual('No subscribers.',
65+ no_subs_nodes.item(0).get('text'));
66+ }
67+}));
68+
69+
70 Y.lp.testing.Runner.run(suite);
71
72 });