← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~gary/launchpad/bug770217 into lp:launchpad

 

Gary Poster has proposed merging lp:~gary/launchpad/bug770217 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #770217 in Launchpad itself: "bug +subscriptions page shows incorrect summary/options when user only has structural subscriptions"
  https://bugs.launchpad.net/launchpad/+bug/770217

For more details, see:
https://code.launchpad.net/~gary/launchpad/bug770217/+merge/58958

This branch adds a test for a problem that structural subscriptions did not trigger the appropriate summary and options for the new bug +subscriptions page, and fixes the problem.

lint is happy.

Thank you

-- 
https://code.launchpad.net/~gary/launchpad/bug770217/+merge/58958
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gary/launchpad/bug770217 into lp:launchpad.
=== modified file 'lib/lp/bugs/javascript/subscription.js'
--- lib/lp/bugs/javascript/subscription.js	2011-04-21 15:31:19 +0000
+++ lib/lp/bugs/javascript/subscription.js	2011-04-25 13:37:29 +0000
@@ -707,7 +707,7 @@
     var reasons = namespace._reasons;
     var reductions = [];
     var increases = [];
-    if (info.count === 0) {
+    if (info.count === 0 && !has_structural_subscriptions()) {
         // The user has no subscriptions at all.
         reason = reasons.NOT_SUBSCRIBED;
         increases.push(action_ids.subscribe_all);

=== modified file 'lib/lp/bugs/javascript/tests/test_subscription.js'
--- lib/lp/bugs/javascript/tests/test_subscription.js	2011-04-21 13:20:51 +0000
+++ lib/lp/bugs/javascript/tests/test_subscription.js	2011-04-25 13:37:29 +0000
@@ -960,6 +960,14 @@
         }
     },
 
+    setUp: function() {
+        window.LP = {cache: {subscription_info: []}};
+    },
+
+    tearDown: function() {
+        delete window.LP;
+    },
+
     test_multiple_direct_subscriptions: function() {
         // It should not be possible to have multiple direct,
         // personal subscriptions.
@@ -993,6 +1001,29 @@
             direct_info.increases);
     },
 
+    test_only_structural_subscriptions: function() {
+        // There are only structural subscriptions.
+        var info = {
+            direct: _constructCategory(),
+            from_duplicates: _constructCategory()
+        };
+        info.count = info.direct.count + info.from_duplicates.count;
+        window.LP.cache.subscription_info.push(true);
+
+        direct_info = module._get_direct_subscription_information(info);
+        Y.Assert.areSame(
+            module._reasons.NOT_PERSONALLY_SUBSCRIBED,
+            direct_info.reason);
+        Y.ArrayAssert.itemsAreEqual(
+            ['mute-direct-subscription',
+             'select-only-direct-subscription-metadata',
+             'select-only-direct-subscription-lifecycle'],
+            direct_info.reductions);
+        Y.ArrayAssert.itemsAreEqual(
+            [],
+            direct_info.increases);
+    },
+
     test_no_direct_subscriptions: function() {
         // There is no direct subscription, but there are
         // other subscriptions.