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

Proposed by Gary Poster
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: 12916
Proposed branch: lp:~gary/launchpad/bug770217
Merge into: lp:launchpad
Diff against target: 61 lines (+32/-1)
2 files modified
lib/lp/bugs/javascript/subscription.js (+1/-1)
lib/lp/bugs/javascript/tests/test_subscription.js (+31/-0)
To merge this branch: bzr merge lp:~gary/launchpad/bug770217
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+58958@code.launchpad.net

Commit message

[r=benji][bug=770217] structural subscriptions should trigger appropriate description and options on bug's +subscriptions page

Description of the change

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

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good.

If I remove the change to lib/lp/bugs/javascript/subscription.js the new test in lib/lp/bugs/javascript/tests/test_subscription.js fails as would be expected.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/javascript/subscription.js'
2--- lib/lp/bugs/javascript/subscription.js 2011-04-21 15:31:19 +0000
3+++ lib/lp/bugs/javascript/subscription.js 2011-04-25 13:37:29 +0000
4@@ -707,7 +707,7 @@
5 var reasons = namespace._reasons;
6 var reductions = [];
7 var increases = [];
8- if (info.count === 0) {
9+ if (info.count === 0 && !has_structural_subscriptions()) {
10 // The user has no subscriptions at all.
11 reason = reasons.NOT_SUBSCRIBED;
12 increases.push(action_ids.subscribe_all);
13
14=== modified file 'lib/lp/bugs/javascript/tests/test_subscription.js'
15--- lib/lp/bugs/javascript/tests/test_subscription.js 2011-04-21 13:20:51 +0000
16+++ lib/lp/bugs/javascript/tests/test_subscription.js 2011-04-25 13:37:29 +0000
17@@ -960,6 +960,14 @@
18 }
19 },
20
21+ setUp: function() {
22+ window.LP = {cache: {subscription_info: []}};
23+ },
24+
25+ tearDown: function() {
26+ delete window.LP;
27+ },
28+
29 test_multiple_direct_subscriptions: function() {
30 // It should not be possible to have multiple direct,
31 // personal subscriptions.
32@@ -993,6 +1001,29 @@
33 direct_info.increases);
34 },
35
36+ test_only_structural_subscriptions: function() {
37+ // There are only structural subscriptions.
38+ var info = {
39+ direct: _constructCategory(),
40+ from_duplicates: _constructCategory()
41+ };
42+ info.count = info.direct.count + info.from_duplicates.count;
43+ window.LP.cache.subscription_info.push(true);
44+
45+ direct_info = module._get_direct_subscription_information(info);
46+ Y.Assert.areSame(
47+ module._reasons.NOT_PERSONALLY_SUBSCRIBED,
48+ direct_info.reason);
49+ Y.ArrayAssert.itemsAreEqual(
50+ ['mute-direct-subscription',
51+ 'select-only-direct-subscription-metadata',
52+ 'select-only-direct-subscription-lifecycle'],
53+ direct_info.reductions);
54+ Y.ArrayAssert.itemsAreEqual(
55+ [],
56+ direct_info.increases);
57+ },
58+
59 test_no_direct_subscriptions: function() {
60 // There is no direct subscription, but there are
61 // other subscriptions.