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

Proposed by Colin Watson
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 Approve
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.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/templates/configure-code-macros.pt'
--- lib/lp/code/templates/configure-code-macros.pt 2015-06-24 21:22:17 +0000
+++ lib/lp/code/templates/configure-code-macros.pt 2016-01-14 15:48:18 +0000
@@ -30,7 +30,7 @@
30 </p>30 </p>
31 </div>31 </div>
3232
33 <div metal:define-macro="no-keys" condition="not:view/user/sshkeys">33 <div metal:define-macro="no-keys" tal:condition="not:view/user/sshkeys">
34 <p class="infobox">To authenticate with the Launchpad branch upload service, you need to34 <p class="infobox">To authenticate with the Launchpad branch upload service, you need to
35 <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">35 <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">
36 register an SSH key</a>.</p>36 register an SSH key</a>.</p>
3737
=== modified file 'lib/lp/registry/browser/tests/test_product_views.py'
--- lib/lp/registry/browser/tests/test_product_views.py 2015-07-01 09:31:48 +0000
+++ lib/lp/registry/browser/tests/test_product_views.py 2016-01-14 15:48:18 +0000
@@ -1,10 +1,13 @@
1# Copyright 2011-2015 Canonical Ltd. This software is licensed under the1# Copyright 2011-2016 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""View tests for Product pages."""4"""View tests for Product pages."""
55
6__metaclass__ = type6__metaclass__ = type
77
8import re
9
10from testtools.matchers import Not
8import soupmatchers11import soupmatchers
9from zope.component import getUtility12from zope.component import getUtility
10from zope.security.proxy import removeSecurityProxy13from zope.security.proxy import removeSecurityProxy
@@ -22,6 +25,10 @@
2225
23 layer = DatabaseFunctionalLayer26 layer = DatabaseFunctionalLayer
2427
28 editsshkeys_tag = soupmatchers.Tag(
29 'edit SSH keys', 'a', text=re.compile('register an SSH key'),
30 attrs={'href': re.compile(r'/\+editsshkeys$')})
31
25 def getBrowser(self, project, view_name=None):32 def getBrowser(self, project, view_name=None):
26 project = removeSecurityProxy(project)33 project = removeSecurityProxy(project)
27 url = canonical_url(project, view_name=view_name)34 url = canonical_url(project, view_name=view_name)
@@ -58,3 +65,18 @@
58 'success-div', 'div', attrs={'class': 'informational message'},65 'success-div', 'div', attrs={'class': 'informational message'},
59 text='Project settings updated.')66 text='Project settings updated.')
60 self.assertThat(browser.contents, soupmatchers.HTMLContains(tag))67 self.assertThat(browser.contents, soupmatchers.HTMLContains(tag))
68
69 def test_editsshkeys_link_if_no_keys_registered(self):
70 project = self.factory.makeProduct()
71 browser = self.getBrowser(project, '+configure-code')
72 self.assertThat(
73 browser.contents, soupmatchers.HTMLContains(self.editsshkeys_tag))
74
75 def test_no_editsshkeys_link_if_keys_registered(self):
76 project = self.factory.makeProduct()
77 with person_logged_in(project.owner):
78 self.factory.makeSSHKey(person=project.owner)
79 browser = self.getBrowser(project, '+configure-code')
80 self.assertThat(
81 browser.contents,
82 Not(soupmatchers.HTMLContains(self.editsshkeys_tag)))