Merge lp:~bac/launchpad/bug-761124 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: 12865
Proposed branch: lp:~bac/launchpad/bug-761124
Merge into: lp:launchpad
Diff against target: 95 lines (+21/-9)
4 files modified
lib/lp/registry/browser/milestone.py (+3/-0)
lib/lp/registry/browser/tests/test_milestone.py (+3/-3)
lib/lp/registry/browser/tests/test_subscription_links.py (+8/-0)
lib/lp/registry/templates/milestone-index.pt (+7/-6)
To merge this branch: bzr merge lp:~bac/launchpad/bug-761124
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+58140@code.launchpad.net

Commit message

[r=benji][bug=761124] Retarget an overly restrictive conditional in the milestone index template.

Description of the change

= Summary =

The JavaScript on the milestone page was not being called to transform
the subscription link.

== Proposed fix ==

The <script> is inside <tal:head-epilogue> which had a conditional
preventing it from being rendered and executed. Move the condition to
surround only those parts it applies to.

Once the JS was called it became obvious that the required data was not
being exposed in LP.cache.

Tests have been added to ensure the setup call is rendered in the HTML
and that the cache is populated.

== Pre-implementation notes ==

None.

== Implementation details ==

As above.

== Tests ==

bin/test -vvt test_subscription_links

== Demo and Q/A ==

https://launchpad.dev/firefox/+milestone/1.0 should show a green
'Subscribe to bug mail' link for any logged in user.

= Launchpad lint =

Will fix.

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/templates/milestone-index.pt
  lib/lp/registry/browser/milestone.py
  lib/lp/registry/browser/tests/test_subscription_links.py

./lib/lp/registry/browser/tests/test_subscription_links.py
      84: E302 expected 2 blank lines, found 1

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

Looks good.

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/registry/browser/milestone.py'
2--- lib/lp/registry/browser/milestone.py 2011-03-29 22:34:04 +0000
3+++ lib/lp/registry/browser/milestone.py 2011-04-19 01:04:17 +0000
4@@ -56,6 +56,7 @@
5 from lp.app.widgets.date import DateWidget
6 from lp.bugs.browser.bugtask import BugTaskListingItem
7 from lp.bugs.browser.structuralsubscription import (
8+ expose_structural_subscription_data_to_js,
9 StructuralSubscriptionMenuMixin,
10 StructuralSubscriptionTargetTraversalMixin,
11 )
12@@ -212,6 +213,8 @@
13 """See `LaunchpadView`."""
14 self.form = self.request.form
15 self.processDeleteFiles()
16+ expose_structural_subscription_data_to_js(
17+ self.context, self.request, self.user)
18
19 @property
20 def expire_cache_minutes(self):
21
22=== modified file 'lib/lp/registry/browser/tests/test_milestone.py'
23--- lib/lp/registry/browser/tests/test_milestone.py 2011-03-03 22:57:03 +0000
24+++ lib/lp/registry/browser/tests/test_milestone.py 2011-04-19 01:04:17 +0000
25@@ -239,7 +239,7 @@
26 def test_milestone_eager_loading(self):
27 # Verify that the number of queries does not increase with more
28 # bugs with different assignees.
29- browses_under_limit = BrowsesWithQueryLimit(35, self.owner)
30+ browses_under_limit = BrowsesWithQueryLimit(36, self.owner)
31 self.add_bug(3)
32 self.assertThat(self.milestone, browses_under_limit)
33 self.add_bug(10)
34@@ -253,7 +253,7 @@
35 # is very large already, if the test fails due to such a change,
36 # please cut some more of the existing fat out of it rather than
37 # increasing the cap.
38- page_query_limit = 36
39+ page_query_limit = 37
40 product = self.factory.makeProduct()
41 login_person(product.owner)
42 milestone = self.factory.makeMilestone(
43@@ -423,7 +423,7 @@
44 def test_milestone_eager_loading(self):
45 # Verify that the number of queries does not increase with more
46 # bugs with different assignees.
47- browses_under_limit = BrowsesWithQueryLimit(34, self.owner)
48+ browses_under_limit = BrowsesWithQueryLimit(35, self.owner)
49 self.add_bug(4)
50 self.assertThat(self.milestone, browses_under_limit)
51 self.add_bug(10)
52
53=== modified file 'lib/lp/registry/browser/tests/test_subscription_links.py'
54--- lib/lp/registry/browser/tests/test_subscription_links.py 2011-04-13 17:58:31 +0000
55+++ lib/lp/registry/browser/tests/test_subscription_links.py 2011-04-19 01:04:17 +0000
56@@ -72,6 +72,14 @@
57 self.assertNotEqual(
58 None, self.new_edit_link,
59 "Expected edit_bug_mail link missing")
60+ # Ensure the LP.cache has been populated.
61+ self.assertTrue("LP.cache['administratedTeams']" in self.contents)
62+ # And that the call to setup the subscription is in the HTML. A
63+ # windmill test is required to ensure that the call actually
64+ # succeeded, by checking the link class for 'js-action'.
65+ setup = ("""module.setup({content_box: """
66+ """"#structural-subscription-content-box"});""")
67+ self.assertTrue(setup in self.contents)
68
69
70 class _TestStructSubs(TestCaseWithFactory, _TestResultsMixin):
71
72=== modified file 'lib/lp/registry/templates/milestone-index.pt'
73--- lib/lp/registry/templates/milestone-index.pt 2011-04-13 01:19:03 +0000
74+++ lib/lp/registry/templates/milestone-index.pt 2011-04-19 01:04:17 +0000
75@@ -6,13 +6,14 @@
76 metal:use-macro="view/macro:page/main_side"
77 i18n:domain="launchpad">
78
79- <tal:head-epilogue metal:fill-slot="head_epilogue"
80- condition="view/is_project_milestone">
81- <style id="hide-side-portlets" type="text/css">
82+ <tal:head-epilogue metal:fill-slot="head_epilogue">
83+ <tal:is_project condition="view/is_project_milestone">
84+ <style id="hide-side-portlets" type="text/css">
85 .side {
86- background: #fff;
87- }
88- </style>
89+ background: #fff;
90+ }
91+ </style>
92+ </tal:is_project>
93 <tal:uses_launchpad_bugtracker
94 condition="context/target/bug_tracking_usage/enumvalue:LAUNCHPAD">
95 <script type="text/javascript"