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
=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
--- lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-15 03:42:02 +0000
+++ lib/lp/app/javascript/subscribers/subscribers_list.js 2011-08-30 13:08:25 +0000
@@ -79,6 +79,7 @@
79 this[config_var] = config[config_var];79 this[config_var] = config[config_var];
80 } else {80 } else {
81 this[config_var] = CONFIG_DEFAULTS[config_var];81 this[config_var] = CONFIG_DEFAULTS[config_var];
82 config[config_var] = CONFIG_DEFAULTS[config_var];
82 }83 }
83 }84 }
84 }85 }
8586
=== modified file 'lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js'
--- lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-15 03:42:02 +0000
+++ lib/lp/app/javascript/subscribers/tests/test_subscribers_list.js 2011-08-30 13:08:25 +0000
@@ -2734,6 +2734,56 @@
2734 }2734 }
2735}));2735}));
27362736
2737/**
2738 * Re-test several resetNoSubscribers() tests that need config options merging
2739 * (LP Bug 837290)
2740 */
2741suite.add(new Y.Test.Case({
2742 name: 'SubscribersLoader.SubscribersList.resetNoSubscribers() re-test',
2743
2744 setUp: function() {
2745 this.root = Y.Node.create('<div />');
2746 Y.one('body').appendChild(this.root);
2747 },
2748
2749 tearDown: function() {
2750 this.root.remove();
2751 },
2752
2753 test_no_subscribers: function() {
2754 // When resetNoSubscribers() is called on an empty
2755 // SubscribersList, indication of no subscribers is added.
2756 // In addition, this checks that the default configuration options
2757 // have been correctly merged without SubscribersLoader()
2758 var loader = setUpLoader(this.root);
2759 var subscribers_list = loader.subscribers_list;
2760 subscribers_list.resetNoSubscribers();
2761 var no_subs_nodes = this.root.all(
2762 '.no-subscribers-indicator');
2763 Y.Assert.areEqual(1, no_subs_nodes.size());
2764 Y.Assert.areEqual('No other subscribers.',
2765 no_subs_nodes.item(0).get('text'));
2766 },
2767
2768 test_no_subscribers_no_levels: function() {
2769 // When resetNoSubscribers() is called on an empty
2770 // SubscribersList, indication of no subscribers is added. If there
2771 // are no subscriber_levels, a different message is displayed.
2772 // In addition, this checks that the default configuration options
2773 // have been correctly merged without SubscribersLoader()
2774 var loader = setUpLoader(this.root);
2775 var subscribers_list = loader.subscribers_list;
2776 subscribers_list.subscriber_levels = [];
2777 subscribers_list.resetNoSubscribers();
2778 var no_subs_nodes = this.root.all(
2779 '.no-subscribers-indicator');
2780 Y.Assert.areEqual(1, no_subs_nodes.size());
2781 Y.Assert.areEqual('No subscribers.',
2782 no_subs_nodes.item(0).get('text'));
2783 }
2784}));
2785
2786
2737Y.lp.testing.Runner.run(suite);2787Y.lp.testing.Runner.run(suite);
27382788
2739});2789});