Merge lp:~cjwatson/launchpad/stray-editsshkeys-link into lp:launchpad

Proposed by Colin Watson on 2016-01-14
Status: Merged
Merged at revision: 17890
Proposed branch: lp:~cjwatson/launchpad/stray-editsshkeys-link
Merge into: lp:launchpad
Diff against target: 61 lines (+24/-2)
2 files modified
lib/lp/code/templates/configure-code-macros.pt (+1/-1)
lib/lp/registry/browser/tests/test_product_views.py (+23/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/stray-editsshkeys-link
Reviewer Review Type Date Requested Status
William Grant code 2016-01-14 Approve on 2016-01-15
Review via email: mp+282612@code.launchpad.net

Commit message

Fix stray link to +editsshkeys on Product:+configure-code when SSH keys were already registered.

Description of the change

Fix stray link to +editsshkeys on Product:+configure-code when SSH keys were already registered.

To post a comment you must log in.
William Grant (wgrant) :
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/code/templates/configure-code-macros.pt'
2--- lib/lp/code/templates/configure-code-macros.pt 2015-06-24 21:22:17 +0000
3+++ lib/lp/code/templates/configure-code-macros.pt 2016-01-14 15:48:18 +0000
4@@ -30,7 +30,7 @@
5 </p>
6 </div>
7
8- <div metal:define-macro="no-keys" condition="not:view/user/sshkeys">
9+ <div metal:define-macro="no-keys" tal:condition="not:view/user/sshkeys">
10 <p class="infobox">To authenticate with the Launchpad branch upload service, you need to
11 <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">
12 register an SSH key</a>.</p>
13
14=== modified file 'lib/lp/registry/browser/tests/test_product_views.py'
15--- lib/lp/registry/browser/tests/test_product_views.py 2015-07-01 09:31:48 +0000
16+++ lib/lp/registry/browser/tests/test_product_views.py 2016-01-14 15:48:18 +0000
17@@ -1,10 +1,13 @@
18-# Copyright 2011-2015 Canonical Ltd. This software is licensed under the
19+# Copyright 2011-2016 Canonical Ltd. This software is licensed under the
20 # GNU Affero General Public License version 3 (see the file LICENSE).
21
22 """View tests for Product pages."""
23
24 __metaclass__ = type
25
26+import re
27+
28+from testtools.matchers import Not
29 import soupmatchers
30 from zope.component import getUtility
31 from zope.security.proxy import removeSecurityProxy
32@@ -22,6 +25,10 @@
33
34 layer = DatabaseFunctionalLayer
35
36+ editsshkeys_tag = soupmatchers.Tag(
37+ 'edit SSH keys', 'a', text=re.compile('register an SSH key'),
38+ attrs={'href': re.compile(r'/\+editsshkeys$')})
39+
40 def getBrowser(self, project, view_name=None):
41 project = removeSecurityProxy(project)
42 url = canonical_url(project, view_name=view_name)
43@@ -58,3 +65,18 @@
44 'success-div', 'div', attrs={'class': 'informational message'},
45 text='Project settings updated.')
46 self.assertThat(browser.contents, soupmatchers.HTMLContains(tag))
47+
48+ def test_editsshkeys_link_if_no_keys_registered(self):
49+ project = self.factory.makeProduct()
50+ browser = self.getBrowser(project, '+configure-code')
51+ self.assertThat(
52+ browser.contents, soupmatchers.HTMLContains(self.editsshkeys_tag))
53+
54+ def test_no_editsshkeys_link_if_keys_registered(self):
55+ project = self.factory.makeProduct()
56+ with person_logged_in(project.owner):
57+ self.factory.makeSSHKey(person=project.owner)
58+ browser = self.getBrowser(project, '+configure-code')
59+ self.assertThat(
60+ browser.contents,
61+ Not(soupmatchers.HTMLContains(self.editsshkeys_tag)))