You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/12/15 13:32:05 UTC
[07/15] allura git commit: ticket:866 added tests 2 tests
ticket:866 added tests 2 tests
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/58a993c7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/58a993c7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/58a993c7
Branch: refs/heads/ib/5940a
Commit: 58a993c7226934c79471975be80c2ef09deccb13
Parents: 401cb4f
Author: DeV1doR <de...@ukr.net>
Authored: Thu Dec 3 18:55:53 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Dec 15 13:19:25 2015 +0200
----------------------------------------------------------------------
Allura/allura/lib/app_globals.py | 5 +-
Allura/allura/nf/allura/css/site_style.css | 11 ++--
.../templates/jinja_master/theme_macros.html | 18 +++----
Allura/allura/tests/functional/test_auth.py | 4 +-
Allura/allura/tests/functional/test_nav.py | 56 ++++++++++++++++++++
Allura/development.ini | 4 +-
6 files changed, 77 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/58a993c7/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 43840b0..84ea20e 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -600,11 +600,14 @@ class Globals(object):
@LazyProperty
def global_nav(self):
+ if not config.get('global_nav', False):
+ return []
+
return json.loads(config.get('global_nav'))
@LazyProperty
def nav_logo(self):
- logo = json.loads(config.get('logo'))
+ logo = json.loads(config.get('logo').replace("\'", '"'))
image_path = logo.get('image_path', False)
if not image_path:
return {}
http://git-wip-us.apache.org/repos/asf/allura/blob/58a993c7/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 19ce6b1..53f3a5b 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -495,16 +495,15 @@ blockquote {
}
/* nav */
-.nav-left {
+nav .link-left {
float: left;
}
-.nav-right {
+nav .link-right {
float: right;
}
-.nav-logo {
- vertical-align: top;
- margin-bottom: 5px;
-}
+/*.link-right, .link-left {
+ line-height: 45px;
+}*/
/* logo */
.logo {
http://git-wip-us.apache.org/repos/asf/allura/blob/58a993c7/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index 3bede3e..40f03dc 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -27,24 +27,22 @@ http://stackoverflow.com/questions/26582731/redefining-imported-jinja-macros
{%- macro header(login_url, logout_url) %}
<header id="site-header">
<div class="wrapper">
- <nav class="nav-left">
+ <nav>
{% if g.nav_logo %}
- <a href="{{ g.nav_logo['redirect_link'] }}"><img class="nav-logo" src="{{ g.nav_logo['image_path'] }}" /></a>
+ <a class="link-left" href="{{ g.nav_logo['redirect_link'] }}"><img class="nav-logo" src="{{ g.nav_logo['image_path'] }}" /></a>
{% endif %}
{% for nav_link in g.global_nav %}
- <a href="{{ nav_link['url'] }}">{{ nav_link['title'] }}</a>
+ <a class="link-left" href="{{ nav_link['url'] }}">{{ nav_link['title'] }}</a>
{% endfor %}
- </nav>
- <nav class="nav-right">
{% if c.user._id %}
- <a href="/auth/preferences/">Account</a>
- <a href="{{c.user.url()}}">{{name}}</a>
- <a href="{{logout_url}}">Log Out</a>
+ <a class="link-right" href="/auth/preferences/">Account</a>
+ <a class="link-right" href="{{c.user.url()}}">{{name}}</a>
+ <a class="link-right" href="{{logout_url}}">Log Out</a>
{% else %}
{% if h.asbool(config.get('auth.allow_user_registration', True)) %}
- <a href="/auth/create_account">Register</a>
+ <a class="link-right" href="/auth/create_account">Register</a>
{% endif %}
- <a href="{{login_url}}">Log In</a>
+ <a class="link-right" href="{{login_url}}">Log In</a>
{% endif %}
</nav>
</div>
http://git-wip-us.apache.org/repos/asf/allura/blob/58a993c7/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 62b14d0..ed926da 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -87,12 +87,12 @@ class TestAuth(TestController):
f['password'] = 'foo'
r = f.submit().follow()
logged_in_session = r.session['_id']
- assert_equal(r.html.findAll('nav')[1]('a')[-1].string, "Log Out")
+ assert_equal(r.html.nav('a')[-1].string, "Log Out")
r = self.app.get('/auth/logout').follow()
logged_out_session = r.session['_id']
assert logged_in_session is not logged_out_session
- assert_equal(r.html.findAll('nav')[1]('a')[-1].string, 'Log In')
+ assert_equal(r.html.nav('a')[-1].string, 'Log In')
def test_track_login(self):
user = M.User.by_username('test-user')
http://git-wip-us.apache.org/repos/asf/allura/blob/58a993c7/Allura/allura/tests/functional/test_nav.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_nav.py b/Allura/allura/tests/functional/test_nav.py
new file mode 100644
index 0000000..306d2e1
--- /dev/null
+++ b/Allura/allura/tests/functional/test_nav.py
@@ -0,0 +1,56 @@
+import mock
+import json
+from tg import config
+
+from allura.tests import TestController
+from allura.lib import helpers as h
+
+
+class TestNavigation(TestController):
+ """
+ Test left navigation in top nav.
+ - Test of global_nav links.
+ - Test of logo.
+ """
+
+ def setUp(self):
+ super(TestNavigation, self).setUp()
+
+ def test_global_nav_links_present(self):
+ data = {"title": "Link Test", "url": "http://example.com"}
+ with h.push_config(config, **{"global_nav": json.dumps([data])}):
+ response = self.app.get('/')
+ assert response.html.nav('a')[0].text == \
+ data['title']
+ assert response.html.nav('a')[0].attrs[-1][-1] == \
+ data['url']
+
+ def test_logo_absent_if_not_image_path(self):
+ data = {"redirect_link": "/", "image_path": "bad_image.png"}
+ with h.push_config(config, **{"logo": json.dumps(data)}):
+ response = self.app.get('/')
+ self.logo = json.loads(config.get('logo'))
+ main_page_link = response.html.nav('a')[0].attrs[-1][-1]
+ assert main_page_link != self.logo['redirect_link']
+
+ # @mock.patch('allura.lib.app_globals.os.path.exists')
+ # def test_logo_present(self, path_exists):
+ # path_exists.return_value = True
+ # data = {"redirect_link": "/", "image_path": "user123.png"}
+ # with h.push_config(config, **{"logo": json.dumps(data)}):
+ # response = self.app.get('/')
+ # self.logo = json.loads(config.get('logo'))
+ # main_page_link = response.html.nav('a')[0].attrs[-1][-1]
+ # image_link = response.html.html.nav('a')[0].img.attrs[-1][-1]
+ # assert main_page_link == self.logo['redirect_link']
+ # assert self.logo['image_path'] in image_link
+
+ # @mock.patch("allura.lib.app_globals.config")
+ # def test_logo_redirect_url_absent_and_set_default(self, _config):
+ # _config.get('logo').return_value = str({
+ # "redirect_link": "/",
+ # "image_path": "a.png"
+ # })
+ # response = self.app.get('/')
+ # main_page_link = response.html.findAll('nav')[0]('a')[0].attrs[-1][-1]
+ # assert main_page_link == '/'
http://git-wip-us.apache.org/repos/asf/allura/blob/58a993c7/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 02808ae..057850c 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -86,7 +86,7 @@ forgemail.url = http://localhost:8080
; NOTE: specify your static.url_base before config this
; Save your picture in images folder
; Example: ../<static_path>/images/<logo_path>
-; logo = {"redirect_link": "/", "image_path": "al.png"}
+; logo = {"redirect_link": "/", "image_path": "user.png"}
; Used to uniquify references to static resources, can be a timestamp or any unique value
; This should be updated each time you deploy (or make significant changes, like new tools, new css)
@@ -497,7 +497,7 @@ limit_param_max = 500
;
; Override this to specify your custom navigation links
;
-global_nav = [{"title": "Link 1", "url": "http://example.com"}, {"title": "Link 2", "url": "http://example.com"}, {"title": "Link 3", "url": "http://example.com"}, {"title": "Link 4", "url": "http://example.com"}, {"title": "Link 5", "url": "http://example.com"}, {"title": "Link 6", "url": "http://example.com"}, {"title": "Link 7", "url": "http://example.com"}]
+global_nav = [{"title": "Link 1", "url": "http://example.com"}]
;