Show More
@@ -0,0 +1,7 b'' | |||||
|
1 | <link rel="import" href="../../../../../../bower_components/polymer/polymer.html"> | |||
|
2 | <dom-module id="rhodecode-legacy-js"> | |||
|
3 | <template> | |||
|
4 | <script src="../../../scripts.js"></script> | |||
|
5 | </template> | |||
|
6 | <script src="rhodecode-legacy-js.js"></script> | |||
|
7 | </dom-module> |
@@ -1,8 +1,9 b'' | |||||
1 | <!-- required for stamped out templates that might use common elements --> |
|
1 | <!-- required for stamped out templates that might use common elements --> | |
|
2 | <link rel="import" href="rhodecode-legacy-js/rhodecode-legacy-js.html"> | |||
2 | <link rel="import" href="../../../../../bower_components/iron-ajax/iron-ajax.html"> |
|
3 | <link rel="import" href="../../../../../bower_components/iron-ajax/iron-ajax.html"> | |
3 | <link rel="import" href="shared-styles.html"> |
|
4 | <link rel="import" href="shared-styles.html"> | |
4 | <link rel="import" href="channelstream-connection/channelstream-connection.html"> |
|
5 | <link rel="import" href="channelstream-connection/channelstream-connection.html"> | |
5 | <link rel="import" href="rhodecode-toast/rhodecode-toast.html"> |
|
6 | <link rel="import" href="rhodecode-toast/rhodecode-toast.html"> | |
6 | <link rel="import" href="rhodecode-toggle/rhodecode-toggle.html"> |
|
7 | <link rel="import" href="rhodecode-toggle/rhodecode-toggle.html"> | |
7 | <link rel="import" href="rhodecode-unsafe-html/rhodecode-unsafe-html.html"> |
|
8 | <link rel="import" href="rhodecode-unsafe-html/rhodecode-unsafe-html.html"> | |
8 | <link rel="import" href="rhodecode-app/rhodecode-app.html"> No newline at end of file |
|
9 | <link rel="import" href="rhodecode-app/rhodecode-app.html"> |
@@ -1,174 +1,173 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <!DOCTYPE html> |
|
2 | <!DOCTYPE html> | |
3 |
|
3 | |||
4 | <% |
|
4 | <% | |
5 | c.template_context['repo_name'] = getattr(c, 'repo_name', '') |
|
5 | c.template_context['repo_name'] = getattr(c, 'repo_name', '') | |
6 |
|
6 | |||
7 | if hasattr(c, 'rhodecode_db_repo'): |
|
7 | if hasattr(c, 'rhodecode_db_repo'): | |
8 | c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type |
|
8 | c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type | |
9 | c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] |
|
9 | c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] | |
10 |
|
10 | |||
11 | if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: |
|
11 | if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: | |
12 | c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username |
|
12 | c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username | |
13 | c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email |
|
13 | c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email | |
14 | c.template_context['rhodecode_user']['notification_status'] = c.rhodecode_user.get_instance().user_data.get('notification_status', True) |
|
14 | c.template_context['rhodecode_user']['notification_status'] = c.rhodecode_user.get_instance().user_data.get('notification_status', True) | |
15 |
|
15 | |||
16 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') |
|
16 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') | |
17 | %> |
|
17 | %> | |
18 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
18 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
19 | <head> |
|
19 | <head> | |
20 | <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}"></script> |
|
20 | <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}"></script> | |
21 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> |
|
21 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> | |
22 | <title>${self.title()}</title> |
|
22 | <title>${self.title()}</title> | |
23 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|
23 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |
24 | <%def name="robots()"> |
|
24 | <%def name="robots()"> | |
25 | <meta name="robots" content="index, nofollow"/> |
|
25 | <meta name="robots" content="index, nofollow"/> | |
26 | </%def> |
|
26 | </%def> | |
27 | ${self.robots()} |
|
27 | ${self.robots()} | |
28 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> |
|
28 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> | |
29 |
|
29 | |||
30 | ## CSS definitions |
|
30 | ## CSS definitions | |
31 | <%def name="css()"> |
|
31 | <%def name="css()"> | |
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
33 | <!--[if lt IE 9]> |
|
33 | <!--[if lt IE 9]> | |
34 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
34 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
35 | <![endif]--> |
|
35 | <![endif]--> | |
36 | ## EXTRA FOR CSS |
|
36 | ## EXTRA FOR CSS | |
37 | ${self.css_extra()} |
|
37 | ${self.css_extra()} | |
38 | </%def> |
|
38 | </%def> | |
39 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites |
|
39 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites | |
40 | <%def name="css_extra()"> |
|
40 | <%def name="css_extra()"> | |
41 | </%def> |
|
41 | </%def> | |
42 |
|
42 | |||
43 | ${self.css()} |
|
43 | ${self.css()} | |
44 |
|
44 | |||
45 | ## JAVASCRIPT |
|
45 | ## JAVASCRIPT | |
46 | <%def name="js()"> |
|
46 | <%def name="js()"> | |
47 | <script> |
|
47 | <script> | |
48 | // setup Polymer options |
|
48 | // setup Polymer options | |
49 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; |
|
49 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; | |
50 |
|
50 | |||
51 | // Load webcomponentsjs polyfill if browser does not support native Web Components |
|
51 | // Load webcomponentsjs polyfill if browser does not support native Web Components | |
52 | (function() { |
|
52 | (function() { | |
53 | 'use strict'; |
|
53 | 'use strict'; | |
54 | var onload = function() { |
|
54 | var onload = function() { | |
55 | // For native Imports, manually fire WebComponentsReady so user code |
|
55 | // For native Imports, manually fire WebComponentsReady so user code | |
56 | // can use the same code path for native and polyfill'd imports. |
|
56 | // can use the same code path for native and polyfill'd imports. | |
57 | if (!window.HTMLImports) { |
|
57 | if (!window.HTMLImports) { | |
58 | document.dispatchEvent( |
|
58 | document.dispatchEvent( | |
59 | new CustomEvent('WebComponentsReady', {bubbles: true}) |
|
59 | new CustomEvent('WebComponentsReady', {bubbles: true}) | |
60 | ); |
|
60 | ); | |
61 | } |
|
61 | } | |
62 | }; |
|
62 | }; | |
63 | var webComponentsSupported = ( |
|
63 | var webComponentsSupported = ( | |
64 | 'registerElement' in document |
|
64 | 'registerElement' in document | |
65 | && 'import' in document.createElement('link') |
|
65 | && 'import' in document.createElement('link') | |
66 | && 'content' in document.createElement('template') |
|
66 | && 'content' in document.createElement('template') | |
67 | ); |
|
67 | ); | |
68 | if (!webComponentsSupported) { |
|
68 | if (!webComponentsSupported) { | |
69 | } else { |
|
69 | } else { | |
70 | onload(); |
|
70 | onload(); | |
71 | } |
|
71 | } | |
72 | })(); |
|
72 | })(); | |
73 | </script> |
|
73 | </script> | |
74 |
|
74 | |||
75 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> |
|
75 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> | |
76 | <script type="text/javascript"> |
|
76 | <script type="text/javascript"> | |
77 | // register templateContext to pass template variables to JS |
|
77 | // register templateContext to pass template variables to JS | |
78 | var templateContext = ${h.json.dumps(c.template_context)|n}; |
|
78 | var templateContext = ${h.json.dumps(c.template_context)|n}; | |
79 |
|
79 | |||
80 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; |
|
80 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; | |
81 | %if hasattr(c, 'rhodecode_db_repo'): |
|
81 | %if hasattr(c, 'rhodecode_db_repo'): | |
82 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; |
|
82 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; | |
83 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; |
|
83 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; | |
84 | %else: |
|
84 | %else: | |
85 | var REPO_LANDING_REV = ''; |
|
85 | var REPO_LANDING_REV = ''; | |
86 | var REPO_TYPE = ''; |
|
86 | var REPO_TYPE = ''; | |
87 | %endif |
|
87 | %endif | |
88 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; |
|
88 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; | |
89 | var ASSET_URL = "${h.asset('')}"; |
|
89 | var ASSET_URL = "${h.asset('')}"; | |
90 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; |
|
90 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; | |
91 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; |
|
91 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; | |
92 | % if getattr(c, 'rhodecode_user', None): |
|
92 | % if getattr(c, 'rhodecode_user', None): | |
93 | var USER = {name:'${c.rhodecode_user.username}'}; |
|
93 | var USER = {name:'${c.rhodecode_user.username}'}; | |
94 | % else: |
|
94 | % else: | |
95 | var USER = {name:null}; |
|
95 | var USER = {name:null}; | |
96 | % endif |
|
96 | % endif | |
97 |
|
97 | |||
98 | var APPENLIGHT = { |
|
98 | var APPENLIGHT = { | |
99 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, |
|
99 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, | |
100 | key: '${getattr(c, "appenlight_api_public_key", "")}', |
|
100 | key: '${getattr(c, "appenlight_api_public_key", "")}', | |
101 | % if getattr(c, 'appenlight_server_url', None): |
|
101 | % if getattr(c, 'appenlight_server_url', None): | |
102 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', |
|
102 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', | |
103 | % endif |
|
103 | % endif | |
104 | requestInfo: { |
|
104 | requestInfo: { | |
105 | % if getattr(c, 'rhodecode_user', None): |
|
105 | % if getattr(c, 'rhodecode_user', None): | |
106 | ip: '${c.rhodecode_user.ip_addr}', |
|
106 | ip: '${c.rhodecode_user.ip_addr}', | |
107 | username: '${c.rhodecode_user.username}' |
|
107 | username: '${c.rhodecode_user.username}' | |
108 | % endif |
|
108 | % endif | |
109 | }, |
|
109 | }, | |
110 | tags: { |
|
110 | tags: { | |
111 | rhodecode_version: '${c.rhodecode_version}', |
|
111 | rhodecode_version: '${c.rhodecode_version}', | |
112 | rhodecode_edition: '${c.rhodecode_edition}' |
|
112 | rhodecode_edition: '${c.rhodecode_edition}' | |
113 | } |
|
113 | } | |
114 | }; |
|
114 | }; | |
115 | </script> |
|
115 | </script> | |
116 | <%include file="/base/plugins_base.html"/> |
|
116 | <%include file="/base/plugins_base.html"/> | |
117 | <!--[if lt IE 9]> |
|
117 | <!--[if lt IE 9]> | |
118 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> |
|
118 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> | |
119 | <![endif]--> |
|
119 | <![endif]--> | |
120 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> |
|
120 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> | |
121 | <script> var alertMessagePayloads = ${h.flash.json_alerts()|n}; </script> |
|
121 | <script> var alertMessagePayloads = ${h.flash.json_alerts()|n}; </script> | |
122 | <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script> |
|
|||
123 | ## avoide escaping the %N |
|
122 | ## avoide escaping the %N | |
|
123 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode-components.js', ver=c.rhodecode_version_hash)}"></script> | |||
124 | <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script> |
|
124 | <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script> | |
125 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode-components.js', ver=c.rhodecode_version_hash)}"></script> |
|
|||
126 |
|
125 | |||
127 |
|
126 | |||
128 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
127 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
129 | ${self.js_extra()} |
|
128 | ${self.js_extra()} | |
130 |
|
129 | |||
131 | <script type="text/javascript"> |
|
130 | <script type="text/javascript"> | |
132 | $(document).ready(function(){ |
|
131 | $(document).ready(function(){ | |
133 | show_more_event(); |
|
132 | show_more_event(); | |
134 | timeagoActivate(); |
|
133 | timeagoActivate(); | |
135 | }) |
|
134 | }) | |
136 | </script> |
|
135 | </script> | |
137 |
|
136 | |||
138 | </%def> |
|
137 | </%def> | |
139 |
|
138 | |||
140 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
139 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
141 | <%def name="js_extra()"></%def> |
|
140 | <%def name="js_extra()"></%def> | |
142 | ${self.js()} |
|
141 | ${self.js()} | |
143 |
|
142 | |||
144 | <%def name="head_extra()"></%def> |
|
143 | <%def name="head_extra()"></%def> | |
145 | ${self.head_extra()} |
|
144 | ${self.head_extra()} | |
146 | ## extra stuff |
|
145 | ## extra stuff | |
147 | %if c.pre_code: |
|
146 | %if c.pre_code: | |
148 | ${c.pre_code|n} |
|
147 | ${c.pre_code|n} | |
149 | %endif |
|
148 | %endif | |
150 | </head> |
|
149 | </head> | |
151 | <body id="body"> |
|
150 | <body id="body"> | |
152 | <noscript> |
|
151 | <noscript> | |
153 | <div class="noscript-error"> |
|
152 | <div class="noscript-error"> | |
154 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} |
|
153 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} | |
155 | </div> |
|
154 | </div> | |
156 | </noscript> |
|
155 | </noscript> | |
157 | ## IE hacks |
|
156 | ## IE hacks | |
158 | <!--[if IE 7]> |
|
157 | <!--[if IE 7]> | |
159 | <script>$(document.body).addClass('ie7')</script> |
|
158 | <script>$(document.body).addClass('ie7')</script> | |
160 | <![endif]--> |
|
159 | <![endif]--> | |
161 | <!--[if IE 8]> |
|
160 | <!--[if IE 8]> | |
162 | <script>$(document.body).addClass('ie8')</script> |
|
161 | <script>$(document.body).addClass('ie8')</script> | |
163 | <![endif]--> |
|
162 | <![endif]--> | |
164 | <!--[if IE 9]> |
|
163 | <!--[if IE 9]> | |
165 | <script>$(document.body).addClass('ie9')</script> |
|
164 | <script>$(document.body).addClass('ie9')</script> | |
166 | <![endif]--> |
|
165 | <![endif]--> | |
167 |
|
166 | |||
168 | ${next.body()} |
|
167 | ${next.body()} | |
169 | %if c.post_code: |
|
168 | %if c.post_code: | |
170 | ${c.post_code|n} |
|
169 | ${c.post_code|n} | |
171 | %endif |
|
170 | %endif | |
172 | <rhodecode-app></rhodecode-app> |
|
171 | <rhodecode-app></rhodecode-app> | |
173 | </body> |
|
172 | </body> | |
174 | </html> |
|
173 | </html> |
@@ -1,390 +1,390 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2010-2016 RhodeCode GmbH |
|
3 | # Copyright (C) 2010-2016 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 | import json |
|
21 | import json | |
22 |
|
22 | |||
23 | from mock import patch |
|
23 | from mock import patch | |
24 | import pytest |
|
24 | import pytest | |
25 | from pylons import tmpl_context as c |
|
25 | from pylons import tmpl_context as c | |
26 |
|
26 | |||
27 | import rhodecode |
|
27 | import rhodecode | |
28 | from rhodecode.lib.utils import map_groups |
|
28 | from rhodecode.lib.utils import map_groups | |
29 | from rhodecode.model.db import Repository, User, RepoGroup |
|
29 | from rhodecode.model.db import Repository, User, RepoGroup | |
30 | from rhodecode.model.meta import Session |
|
30 | from rhodecode.model.meta import Session | |
31 | from rhodecode.model.repo import RepoModel |
|
31 | from rhodecode.model.repo import RepoModel | |
32 | from rhodecode.model.repo_group import RepoGroupModel |
|
32 | from rhodecode.model.repo_group import RepoGroupModel | |
33 | from rhodecode.model.settings import SettingsModel |
|
33 | from rhodecode.model.settings import SettingsModel | |
34 | from rhodecode.tests import TestController, url, TEST_USER_ADMIN_LOGIN |
|
34 | from rhodecode.tests import TestController, url, TEST_USER_ADMIN_LOGIN | |
35 | from rhodecode.tests.fixture import Fixture |
|
35 | from rhodecode.tests.fixture import Fixture | |
36 |
|
36 | |||
37 |
|
37 | |||
38 | fixture = Fixture() |
|
38 | fixture = Fixture() | |
39 |
|
39 | |||
40 |
|
40 | |||
41 | class TestHomeController(TestController): |
|
41 | class TestHomeController(TestController): | |
42 |
|
42 | |||
43 | def test_index(self): |
|
43 | def test_index(self): | |
44 | self.log_user() |
|
44 | self.log_user() | |
45 | response = self.app.get(url(controller='home', action='index')) |
|
45 | response = self.app.get(url(controller='home', action='index')) | |
46 | # if global permission is set |
|
46 | # if global permission is set | |
47 | response.mustcontain('Add Repository') |
|
47 | response.mustcontain('Add Repository') | |
48 |
|
48 | |||
49 | # search for objects inside the JavaScript JSON |
|
49 | # search for objects inside the JavaScript JSON | |
50 | for repo in Repository.getAll(): |
|
50 | for repo in Repository.getAll(): | |
51 | response.mustcontain('"name_raw": "%s"' % repo.repo_name) |
|
51 | response.mustcontain('"name_raw": "%s"' % repo.repo_name) | |
52 |
|
52 | |||
53 | def test_index_contains_statics_with_ver(self): |
|
53 | def test_index_contains_statics_with_ver(self): | |
54 | self.log_user() |
|
54 | self.log_user() | |
55 | response = self.app.get(url(controller='home', action='index')) |
|
55 | response = self.app.get(url(controller='home', action='index')) | |
56 |
|
56 | |||
57 | rhodecode_version_hash = c.rhodecode_version_hash |
|
57 | rhodecode_version_hash = c.rhodecode_version_hash | |
58 | response.mustcontain('style.css?ver={0}'.format(rhodecode_version_hash)) |
|
58 | response.mustcontain('style.css?ver={0}'.format(rhodecode_version_hash)) | |
59 |
response.mustcontain(' |
|
59 | response.mustcontain('rhodecode-components.js?ver={0}'.format(rhodecode_version_hash)) | |
60 |
|
60 | |||
61 | def test_index_contains_backend_specific_details(self, backend): |
|
61 | def test_index_contains_backend_specific_details(self, backend): | |
62 | self.log_user() |
|
62 | self.log_user() | |
63 | response = self.app.get(url(controller='home', action='index')) |
|
63 | response = self.app.get(url(controller='home', action='index')) | |
64 | tip = backend.repo.get_commit().raw_id |
|
64 | tip = backend.repo.get_commit().raw_id | |
65 |
|
65 | |||
66 | # html in javascript variable: |
|
66 | # html in javascript variable: | |
67 | response.mustcontain(r'<i class=\"icon-%s\"' % (backend.alias, )) |
|
67 | response.mustcontain(r'<i class=\"icon-%s\"' % (backend.alias, )) | |
68 | response.mustcontain(r'href=\"/%s\"' % (backend.repo_name, )) |
|
68 | response.mustcontain(r'href=\"/%s\"' % (backend.repo_name, )) | |
69 |
|
69 | |||
70 | response.mustcontain("""/%s/changeset/%s""" % (backend.repo_name, tip)) |
|
70 | response.mustcontain("""/%s/changeset/%s""" % (backend.repo_name, tip)) | |
71 | response.mustcontain("""Added a symlink""") |
|
71 | response.mustcontain("""Added a symlink""") | |
72 |
|
72 | |||
73 | def test_index_with_anonymous_access_disabled(self): |
|
73 | def test_index_with_anonymous_access_disabled(self): | |
74 | with fixture.anon_access(False): |
|
74 | with fixture.anon_access(False): | |
75 | response = self.app.get(url(controller='home', action='index'), |
|
75 | response = self.app.get(url(controller='home', action='index'), | |
76 | status=302) |
|
76 | status=302) | |
77 | assert 'login' in response.location |
|
77 | assert 'login' in response.location | |
78 |
|
78 | |||
79 | def test_index_page_on_groups(self, autologin_user, repo_group): |
|
79 | def test_index_page_on_groups(self, autologin_user, repo_group): | |
80 | response = self.app.get(url('repo_group_home', group_name='gr1')) |
|
80 | response = self.app.get(url('repo_group_home', group_name='gr1')) | |
81 | response.mustcontain("gr1/repo_in_group") |
|
81 | response.mustcontain("gr1/repo_in_group") | |
82 |
|
82 | |||
83 | def test_index_page_on_group_with_trailing_slash( |
|
83 | def test_index_page_on_group_with_trailing_slash( | |
84 | self, autologin_user, repo_group): |
|
84 | self, autologin_user, repo_group): | |
85 | response = self.app.get(url('repo_group_home', group_name='gr1') + '/') |
|
85 | response = self.app.get(url('repo_group_home', group_name='gr1') + '/') | |
86 | response.mustcontain("gr1/repo_in_group") |
|
86 | response.mustcontain("gr1/repo_in_group") | |
87 |
|
87 | |||
88 | @pytest.fixture(scope='class') |
|
88 | @pytest.fixture(scope='class') | |
89 | def repo_group(self, request): |
|
89 | def repo_group(self, request): | |
90 | gr = fixture.create_repo_group('gr1') |
|
90 | gr = fixture.create_repo_group('gr1') | |
91 | fixture.create_repo(name='gr1/repo_in_group', repo_group=gr) |
|
91 | fixture.create_repo(name='gr1/repo_in_group', repo_group=gr) | |
92 |
|
92 | |||
93 | @request.addfinalizer |
|
93 | @request.addfinalizer | |
94 | def cleanup(): |
|
94 | def cleanup(): | |
95 | RepoModel().delete('gr1/repo_in_group') |
|
95 | RepoModel().delete('gr1/repo_in_group') | |
96 | RepoGroupModel().delete(repo_group='gr1', force_delete=True) |
|
96 | RepoGroupModel().delete(repo_group='gr1', force_delete=True) | |
97 | Session().commit() |
|
97 | Session().commit() | |
98 |
|
98 | |||
99 | def test_index_with_name_with_tags(self, autologin_user): |
|
99 | def test_index_with_name_with_tags(self, autologin_user): | |
100 | user = User.get_by_username('test_admin') |
|
100 | user = User.get_by_username('test_admin') | |
101 | user.name = '<img src="/image1" onload="alert(\'Hello, World!\');">' |
|
101 | user.name = '<img src="/image1" onload="alert(\'Hello, World!\');">' | |
102 | user.lastname = ( |
|
102 | user.lastname = ( | |
103 | '<img src="/image2" onload="alert(\'Hello, World!\');">') |
|
103 | '<img src="/image2" onload="alert(\'Hello, World!\');">') | |
104 | Session().add(user) |
|
104 | Session().add(user) | |
105 | Session().commit() |
|
105 | Session().commit() | |
106 |
|
106 | |||
107 | response = self.app.get(url(controller='home', action='index')) |
|
107 | response = self.app.get(url(controller='home', action='index')) | |
108 | response.mustcontain( |
|
108 | response.mustcontain( | |
109 | '<img src="/image1" onload="' |
|
109 | '<img src="/image1" onload="' | |
110 | 'alert('Hello, World!');">') |
|
110 | 'alert('Hello, World!');">') | |
111 | response.mustcontain( |
|
111 | response.mustcontain( | |
112 | '<img src="/image2" onload="' |
|
112 | '<img src="/image2" onload="' | |
113 | 'alert('Hello, World!');">') |
|
113 | 'alert('Hello, World!');">') | |
114 |
|
114 | |||
115 | @pytest.mark.parametrize("name, state", [ |
|
115 | @pytest.mark.parametrize("name, state", [ | |
116 | ('Disabled', False), |
|
116 | ('Disabled', False), | |
117 | ('Enabled', True), |
|
117 | ('Enabled', True), | |
118 | ]) |
|
118 | ]) | |
119 | def test_index_show_version(self, autologin_user, name, state): |
|
119 | def test_index_show_version(self, autologin_user, name, state): | |
120 | version_string = 'RhodeCode Enterprise %s' % rhodecode.__version__ |
|
120 | version_string = 'RhodeCode Enterprise %s' % rhodecode.__version__ | |
121 |
|
121 | |||
122 | sett = SettingsModel().create_or_update_setting( |
|
122 | sett = SettingsModel().create_or_update_setting( | |
123 | 'show_version', state, 'bool') |
|
123 | 'show_version', state, 'bool') | |
124 | Session().add(sett) |
|
124 | Session().add(sett) | |
125 | Session().commit() |
|
125 | Session().commit() | |
126 | SettingsModel().invalidate_settings_cache() |
|
126 | SettingsModel().invalidate_settings_cache() | |
127 |
|
127 | |||
128 | response = self.app.get(url(controller='home', action='index')) |
|
128 | response = self.app.get(url(controller='home', action='index')) | |
129 | if state is True: |
|
129 | if state is True: | |
130 | response.mustcontain(version_string) |
|
130 | response.mustcontain(version_string) | |
131 | if state is False: |
|
131 | if state is False: | |
132 | response.mustcontain(no=[version_string]) |
|
132 | response.mustcontain(no=[version_string]) | |
133 |
|
133 | |||
134 |
|
134 | |||
135 | class TestUserAutocompleteData(TestController): |
|
135 | class TestUserAutocompleteData(TestController): | |
136 | def test_returns_list_of_users(self, user_util): |
|
136 | def test_returns_list_of_users(self, user_util): | |
137 | self.log_user() |
|
137 | self.log_user() | |
138 | user = user_util.create_user(is_active=True) |
|
138 | user = user_util.create_user(is_active=True) | |
139 | user_name = user.username |
|
139 | user_name = user.username | |
140 | response = self.app.get( |
|
140 | response = self.app.get( | |
141 | url(controller='home', action='user_autocomplete_data'), |
|
141 | url(controller='home', action='user_autocomplete_data'), | |
142 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) |
|
142 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) | |
143 | result = json.loads(response.body) |
|
143 | result = json.loads(response.body) | |
144 | values = [suggestion['value'] for suggestion in result['suggestions']] |
|
144 | values = [suggestion['value'] for suggestion in result['suggestions']] | |
145 | assert user_name in values |
|
145 | assert user_name in values | |
146 |
|
146 | |||
147 | def test_returns_inactive_users_when_active_flag_sent(self, user_util): |
|
147 | def test_returns_inactive_users_when_active_flag_sent(self, user_util): | |
148 | self.log_user() |
|
148 | self.log_user() | |
149 | user = user_util.create_user(is_active=False) |
|
149 | user = user_util.create_user(is_active=False) | |
150 | user_name = user.username |
|
150 | user_name = user.username | |
151 | response = self.app.get( |
|
151 | response = self.app.get( | |
152 | url(controller='home', action='user_autocomplete_data', |
|
152 | url(controller='home', action='user_autocomplete_data', | |
153 | user_groups='true', active='0'), |
|
153 | user_groups='true', active='0'), | |
154 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) |
|
154 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) | |
155 | result = json.loads(response.body) |
|
155 | result = json.loads(response.body) | |
156 | values = [suggestion['value'] for suggestion in result['suggestions']] |
|
156 | values = [suggestion['value'] for suggestion in result['suggestions']] | |
157 | assert user_name in values |
|
157 | assert user_name in values | |
158 |
|
158 | |||
159 | def test_returns_groups_when_user_groups_sent(self, user_util): |
|
159 | def test_returns_groups_when_user_groups_sent(self, user_util): | |
160 | self.log_user() |
|
160 | self.log_user() | |
161 | group = user_util.create_user_group(user_groups_active=True) |
|
161 | group = user_util.create_user_group(user_groups_active=True) | |
162 | group_name = group.users_group_name |
|
162 | group_name = group.users_group_name | |
163 | response = self.app.get( |
|
163 | response = self.app.get( | |
164 | url(controller='home', action='user_autocomplete_data', |
|
164 | url(controller='home', action='user_autocomplete_data', | |
165 | user_groups='true'), |
|
165 | user_groups='true'), | |
166 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) |
|
166 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) | |
167 | result = json.loads(response.body) |
|
167 | result = json.loads(response.body) | |
168 | values = [suggestion['value'] for suggestion in result['suggestions']] |
|
168 | values = [suggestion['value'] for suggestion in result['suggestions']] | |
169 | assert group_name in values |
|
169 | assert group_name in values | |
170 |
|
170 | |||
171 | def test_result_is_limited_when_query_is_sent(self): |
|
171 | def test_result_is_limited_when_query_is_sent(self): | |
172 | self.log_user() |
|
172 | self.log_user() | |
173 | fake_result = [ |
|
173 | fake_result = [ | |
174 | { |
|
174 | { | |
175 | 'first_name': 'John', |
|
175 | 'first_name': 'John', | |
176 | 'value_display': 'hello{} (John Smith)'.format(i), |
|
176 | 'value_display': 'hello{} (John Smith)'.format(i), | |
177 | 'icon_link': '/images/user14.png', |
|
177 | 'icon_link': '/images/user14.png', | |
178 | 'value': 'hello{}'.format(i), |
|
178 | 'value': 'hello{}'.format(i), | |
179 | 'last_name': 'Smith', |
|
179 | 'last_name': 'Smith', | |
180 | 'username': 'hello{}'.format(i), |
|
180 | 'username': 'hello{}'.format(i), | |
181 | 'id': i, |
|
181 | 'id': i, | |
182 | 'value_type': u'user' |
|
182 | 'value_type': u'user' | |
183 | } |
|
183 | } | |
184 | for i in range(10) |
|
184 | for i in range(10) | |
185 | ] |
|
185 | ] | |
186 | users_patcher = patch.object( |
|
186 | users_patcher = patch.object( | |
187 | RepoModel, 'get_users', return_value=fake_result) |
|
187 | RepoModel, 'get_users', return_value=fake_result) | |
188 | groups_patcher = patch.object( |
|
188 | groups_patcher = patch.object( | |
189 | RepoModel, 'get_user_groups', return_value=fake_result) |
|
189 | RepoModel, 'get_user_groups', return_value=fake_result) | |
190 |
|
190 | |||
191 | query = 'hello' |
|
191 | query = 'hello' | |
192 | with users_patcher as users_mock, groups_patcher as groups_mock: |
|
192 | with users_patcher as users_mock, groups_patcher as groups_mock: | |
193 | response = self.app.get( |
|
193 | response = self.app.get( | |
194 | url(controller='home', action='user_autocomplete_data', |
|
194 | url(controller='home', action='user_autocomplete_data', | |
195 | user_groups='true', query=query), |
|
195 | user_groups='true', query=query), | |
196 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) |
|
196 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) | |
197 |
|
197 | |||
198 | result = json.loads(response.body) |
|
198 | result = json.loads(response.body) | |
199 | users_mock.assert_called_once_with( |
|
199 | users_mock.assert_called_once_with( | |
200 | name_contains=query, only_active=True) |
|
200 | name_contains=query, only_active=True) | |
201 | groups_mock.assert_called_once_with( |
|
201 | groups_mock.assert_called_once_with( | |
202 | name_contains=query, only_active=True) |
|
202 | name_contains=query, only_active=True) | |
203 | assert len(result['suggestions']) == 20 |
|
203 | assert len(result['suggestions']) == 20 | |
204 |
|
204 | |||
205 |
|
205 | |||
206 | def assert_and_get_content(result): |
|
206 | def assert_and_get_content(result): | |
207 | repos = [] |
|
207 | repos = [] | |
208 | groups = [] |
|
208 | groups = [] | |
209 | commits = [] |
|
209 | commits = [] | |
210 | for data in result: |
|
210 | for data in result: | |
211 | for data_item in data['children']: |
|
211 | for data_item in data['children']: | |
212 | assert data_item['id'] |
|
212 | assert data_item['id'] | |
213 | assert data_item['text'] |
|
213 | assert data_item['text'] | |
214 | assert data_item['url'] |
|
214 | assert data_item['url'] | |
215 | if data_item['type'] == 'repo': |
|
215 | if data_item['type'] == 'repo': | |
216 | repos.append(data_item) |
|
216 | repos.append(data_item) | |
217 | elif data_item['type'] == 'group': |
|
217 | elif data_item['type'] == 'group': | |
218 | groups.append(data_item) |
|
218 | groups.append(data_item) | |
219 | elif data_item['type'] == 'commit': |
|
219 | elif data_item['type'] == 'commit': | |
220 | commits.append(data_item) |
|
220 | commits.append(data_item) | |
221 | else: |
|
221 | else: | |
222 | raise Exception('invalid type %s' % data_item['type']) |
|
222 | raise Exception('invalid type %s' % data_item['type']) | |
223 |
|
223 | |||
224 | return repos, groups, commits |
|
224 | return repos, groups, commits | |
225 |
|
225 | |||
226 |
|
226 | |||
227 | class TestGotoSwitcherData(TestController): |
|
227 | class TestGotoSwitcherData(TestController): | |
228 | required_repos_with_groups = [ |
|
228 | required_repos_with_groups = [ | |
229 | 'abc', |
|
229 | 'abc', | |
230 | 'abc-fork', |
|
230 | 'abc-fork', | |
231 | 'forks/abcd', |
|
231 | 'forks/abcd', | |
232 | 'abcd', |
|
232 | 'abcd', | |
233 | 'abcde', |
|
233 | 'abcde', | |
234 | 'a/abc', |
|
234 | 'a/abc', | |
235 | 'aa/abc', |
|
235 | 'aa/abc', | |
236 | 'aaa/abc', |
|
236 | 'aaa/abc', | |
237 | 'aaaa/abc', |
|
237 | 'aaaa/abc', | |
238 | 'repos_abc/aaa/abc', |
|
238 | 'repos_abc/aaa/abc', | |
239 | 'abc_repos/abc', |
|
239 | 'abc_repos/abc', | |
240 | 'abc_repos/abcd', |
|
240 | 'abc_repos/abcd', | |
241 | 'xxx/xyz', |
|
241 | 'xxx/xyz', | |
242 | 'forked-abc/a/abc' |
|
242 | 'forked-abc/a/abc' | |
243 | ] |
|
243 | ] | |
244 |
|
244 | |||
245 | @pytest.fixture(autouse=True, scope='class') |
|
245 | @pytest.fixture(autouse=True, scope='class') | |
246 | def prepare(self, request, pylonsapp): |
|
246 | def prepare(self, request, pylonsapp): | |
247 | for repo_and_group in self.required_repos_with_groups: |
|
247 | for repo_and_group in self.required_repos_with_groups: | |
248 | # create structure of groups and return the last group |
|
248 | # create structure of groups and return the last group | |
249 |
|
249 | |||
250 | repo_group = map_groups(repo_and_group) |
|
250 | repo_group = map_groups(repo_and_group) | |
251 |
|
251 | |||
252 | RepoModel()._create_repo( |
|
252 | RepoModel()._create_repo( | |
253 | repo_and_group, 'hg', 'test-ac', TEST_USER_ADMIN_LOGIN, |
|
253 | repo_and_group, 'hg', 'test-ac', TEST_USER_ADMIN_LOGIN, | |
254 | repo_group=getattr(repo_group, 'group_id', None)) |
|
254 | repo_group=getattr(repo_group, 'group_id', None)) | |
255 |
|
255 | |||
256 | Session().commit() |
|
256 | Session().commit() | |
257 |
|
257 | |||
258 | request.addfinalizer(self.cleanup) |
|
258 | request.addfinalizer(self.cleanup) | |
259 |
|
259 | |||
260 | def cleanup(self): |
|
260 | def cleanup(self): | |
261 | # first delete all repos |
|
261 | # first delete all repos | |
262 | for repo_and_groups in self.required_repos_with_groups: |
|
262 | for repo_and_groups in self.required_repos_with_groups: | |
263 | repo = Repository.get_by_repo_name(repo_and_groups) |
|
263 | repo = Repository.get_by_repo_name(repo_and_groups) | |
264 | if repo: |
|
264 | if repo: | |
265 | RepoModel().delete(repo) |
|
265 | RepoModel().delete(repo) | |
266 | Session().commit() |
|
266 | Session().commit() | |
267 |
|
267 | |||
268 | # then delete all empty groups |
|
268 | # then delete all empty groups | |
269 | for repo_and_groups in self.required_repos_with_groups: |
|
269 | for repo_and_groups in self.required_repos_with_groups: | |
270 | if '/' in repo_and_groups: |
|
270 | if '/' in repo_and_groups: | |
271 | r_group = repo_and_groups.rsplit('/', 1)[0] |
|
271 | r_group = repo_and_groups.rsplit('/', 1)[0] | |
272 | repo_group = RepoGroup.get_by_group_name(r_group) |
|
272 | repo_group = RepoGroup.get_by_group_name(r_group) | |
273 | if not repo_group: |
|
273 | if not repo_group: | |
274 | continue |
|
274 | continue | |
275 | parents = repo_group.parents |
|
275 | parents = repo_group.parents | |
276 | RepoGroupModel().delete(repo_group, force_delete=True) |
|
276 | RepoGroupModel().delete(repo_group, force_delete=True) | |
277 | Session().commit() |
|
277 | Session().commit() | |
278 |
|
278 | |||
279 | for el in reversed(parents): |
|
279 | for el in reversed(parents): | |
280 | RepoGroupModel().delete(el, force_delete=True) |
|
280 | RepoGroupModel().delete(el, force_delete=True) | |
281 | Session().commit() |
|
281 | Session().commit() | |
282 |
|
282 | |||
283 | def test_returns_list_of_repos_and_groups(self): |
|
283 | def test_returns_list_of_repos_and_groups(self): | |
284 | self.log_user() |
|
284 | self.log_user() | |
285 |
|
285 | |||
286 | response = self.app.get( |
|
286 | response = self.app.get( | |
287 | url(controller='home', action='goto_switcher_data'), |
|
287 | url(controller='home', action='goto_switcher_data'), | |
288 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) |
|
288 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) | |
289 | result = json.loads(response.body)['results'] |
|
289 | result = json.loads(response.body)['results'] | |
290 |
|
290 | |||
291 | repos, groups, commits = assert_and_get_content(result) |
|
291 | repos, groups, commits = assert_and_get_content(result) | |
292 |
|
292 | |||
293 | assert len(repos) == len(Repository.get_all()) |
|
293 | assert len(repos) == len(Repository.get_all()) | |
294 | assert len(groups) == len(RepoGroup.get_all()) |
|
294 | assert len(groups) == len(RepoGroup.get_all()) | |
295 | assert len(commits) == 0 |
|
295 | assert len(commits) == 0 | |
296 |
|
296 | |||
297 | def test_returns_list_of_repos_and_groups_filtered(self): |
|
297 | def test_returns_list_of_repos_and_groups_filtered(self): | |
298 | self.log_user() |
|
298 | self.log_user() | |
299 |
|
299 | |||
300 | response = self.app.get( |
|
300 | response = self.app.get( | |
301 | url(controller='home', action='goto_switcher_data'), |
|
301 | url(controller='home', action='goto_switcher_data'), | |
302 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, |
|
302 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, | |
303 | params={'query': 'abc'}, status=200) |
|
303 | params={'query': 'abc'}, status=200) | |
304 | result = json.loads(response.body)['results'] |
|
304 | result = json.loads(response.body)['results'] | |
305 |
|
305 | |||
306 | repos, groups, commits = assert_and_get_content(result) |
|
306 | repos, groups, commits = assert_and_get_content(result) | |
307 |
|
307 | |||
308 | assert len(repos) == 13 |
|
308 | assert len(repos) == 13 | |
309 | assert len(groups) == 5 |
|
309 | assert len(groups) == 5 | |
310 | assert len(commits) == 0 |
|
310 | assert len(commits) == 0 | |
311 |
|
311 | |||
312 | def test_returns_list_of_properly_sorted_and_filtered(self): |
|
312 | def test_returns_list_of_properly_sorted_and_filtered(self): | |
313 | self.log_user() |
|
313 | self.log_user() | |
314 |
|
314 | |||
315 | response = self.app.get( |
|
315 | response = self.app.get( | |
316 | url(controller='home', action='goto_switcher_data'), |
|
316 | url(controller='home', action='goto_switcher_data'), | |
317 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, |
|
317 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, | |
318 | params={'query': 'abc'}, status=200) |
|
318 | params={'query': 'abc'}, status=200) | |
319 | result = json.loads(response.body)['results'] |
|
319 | result = json.loads(response.body)['results'] | |
320 |
|
320 | |||
321 | repos, groups, commits = assert_and_get_content(result) |
|
321 | repos, groups, commits = assert_and_get_content(result) | |
322 |
|
322 | |||
323 | test_repos = [x['text'] for x in repos[:4]] |
|
323 | test_repos = [x['text'] for x in repos[:4]] | |
324 | assert ['abc', 'abcd', 'a/abc', 'abcde'] == test_repos |
|
324 | assert ['abc', 'abcd', 'a/abc', 'abcde'] == test_repos | |
325 |
|
325 | |||
326 | test_groups = [x['text'] for x in groups[:4]] |
|
326 | test_groups = [x['text'] for x in groups[:4]] | |
327 | assert ['abc_repos', 'repos_abc', |
|
327 | assert ['abc_repos', 'repos_abc', | |
328 | 'forked-abc', 'forked-abc/a'] == test_groups |
|
328 | 'forked-abc', 'forked-abc/a'] == test_groups | |
329 |
|
329 | |||
330 |
|
330 | |||
331 | class TestRepoListData(TestController): |
|
331 | class TestRepoListData(TestController): | |
332 | def test_returns_list_of_repos_and_groups(self, user_util): |
|
332 | def test_returns_list_of_repos_and_groups(self, user_util): | |
333 | self.log_user() |
|
333 | self.log_user() | |
334 |
|
334 | |||
335 | response = self.app.get( |
|
335 | response = self.app.get( | |
336 | url(controller='home', action='repo_list_data'), |
|
336 | url(controller='home', action='repo_list_data'), | |
337 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) |
|
337 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, status=200) | |
338 | result = json.loads(response.body)['results'] |
|
338 | result = json.loads(response.body)['results'] | |
339 |
|
339 | |||
340 | repos, groups, commits = assert_and_get_content(result) |
|
340 | repos, groups, commits = assert_and_get_content(result) | |
341 |
|
341 | |||
342 | assert len(repos) == len(Repository.get_all()) |
|
342 | assert len(repos) == len(Repository.get_all()) | |
343 | assert len(groups) == 0 |
|
343 | assert len(groups) == 0 | |
344 | assert len(commits) == 0 |
|
344 | assert len(commits) == 0 | |
345 |
|
345 | |||
346 | def test_returns_list_of_repos_and_groups_filtered(self): |
|
346 | def test_returns_list_of_repos_and_groups_filtered(self): | |
347 | self.log_user() |
|
347 | self.log_user() | |
348 |
|
348 | |||
349 | response = self.app.get( |
|
349 | response = self.app.get( | |
350 | url(controller='home', action='repo_list_data'), |
|
350 | url(controller='home', action='repo_list_data'), | |
351 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, |
|
351 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, | |
352 | params={'query': 'vcs_test_git'}, status=200) |
|
352 | params={'query': 'vcs_test_git'}, status=200) | |
353 | result = json.loads(response.body)['results'] |
|
353 | result = json.loads(response.body)['results'] | |
354 |
|
354 | |||
355 | repos, groups, commits = assert_and_get_content(result) |
|
355 | repos, groups, commits = assert_and_get_content(result) | |
356 |
|
356 | |||
357 | assert len(repos) == len(Repository.query().filter( |
|
357 | assert len(repos) == len(Repository.query().filter( | |
358 | Repository.repo_name.ilike('%vcs_test_git%')).all()) |
|
358 | Repository.repo_name.ilike('%vcs_test_git%')).all()) | |
359 | assert len(groups) == 0 |
|
359 | assert len(groups) == 0 | |
360 | assert len(commits) == 0 |
|
360 | assert len(commits) == 0 | |
361 |
|
361 | |||
362 | def test_returns_list_of_repos_and_groups_filtered_with_type(self): |
|
362 | def test_returns_list_of_repos_and_groups_filtered_with_type(self): | |
363 | self.log_user() |
|
363 | self.log_user() | |
364 |
|
364 | |||
365 | response = self.app.get( |
|
365 | response = self.app.get( | |
366 | url(controller='home', action='repo_list_data'), |
|
366 | url(controller='home', action='repo_list_data'), | |
367 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, |
|
367 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, | |
368 | params={'query': 'vcs_test_git', 'repo_type': 'git'}, status=200) |
|
368 | params={'query': 'vcs_test_git', 'repo_type': 'git'}, status=200) | |
369 | result = json.loads(response.body)['results'] |
|
369 | result = json.loads(response.body)['results'] | |
370 |
|
370 | |||
371 | repos, groups, commits = assert_and_get_content(result) |
|
371 | repos, groups, commits = assert_and_get_content(result) | |
372 |
|
372 | |||
373 | assert len(repos) == len(Repository.query().filter( |
|
373 | assert len(repos) == len(Repository.query().filter( | |
374 | Repository.repo_name.ilike('%vcs_test_git%')).all()) |
|
374 | Repository.repo_name.ilike('%vcs_test_git%')).all()) | |
375 | assert len(groups) == 0 |
|
375 | assert len(groups) == 0 | |
376 | assert len(commits) == 0 |
|
376 | assert len(commits) == 0 | |
377 |
|
377 | |||
378 | def test_returns_list_of_repos_non_ascii_query(self): |
|
378 | def test_returns_list_of_repos_non_ascii_query(self): | |
379 | self.log_user() |
|
379 | self.log_user() | |
380 | response = self.app.get( |
|
380 | response = self.app.get( | |
381 | url(controller='home', action='repo_list_data'), |
|
381 | url(controller='home', action='repo_list_data'), | |
382 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, |
|
382 | headers={'X-REQUESTED-WITH': 'XMLHttpRequest', }, | |
383 | params={'query': 'ć_vcs_test_ą', 'repo_type': 'git'}, status=200) |
|
383 | params={'query': 'ć_vcs_test_ą', 'repo_type': 'git'}, status=200) | |
384 | result = json.loads(response.body)['results'] |
|
384 | result = json.loads(response.body)['results'] | |
385 |
|
385 | |||
386 | repos, groups, commits = assert_and_get_content(result) |
|
386 | repos, groups, commits = assert_and_get_content(result) | |
387 |
|
387 | |||
388 | assert len(repos) == 0 |
|
388 | assert len(repos) == 0 | |
389 | assert len(groups) == 0 |
|
389 | assert len(groups) == 0 | |
390 | assert len(commits) == 0 |
|
390 | assert len(commits) == 0 |
General Comments 0
You need to be logged in to leave comments.
Login now