Merge "Revert "LocationProvider should be set up on the Horizon App""

This commit is contained in:
Jenkins 2016-01-07 19:06:13 +00:00 committed by Gerrit Code Review
commit 7a1e069af4
2 changed files with 29 additions and 67 deletions

View File

@ -57,21 +57,12 @@
*/ */
angular angular
.module('horizon.app', [] .module('horizon.app', []
.concat(libraryModules) .concat(libraryModules)
.concat(horizonBuiltInModules) .concat(horizonBuiltInModules)
.concat(horizonPlugInModules) .concat(horizonPlugInModules)
) )
.config(configHorizon)
.run(updateHorizon); .run(updateHorizon);
configHorizon.$inject = [
'$locationProvider'
];
function configHorizon($locationProvider) {
$locationProvider.html5Mode(true).hashPrefix('!');
}
updateHorizon.$inject = [ updateHorizon.$inject = [
'gettextCatalog', 'gettextCatalog',
'horizon.framework.conf.spinner_options', 'horizon.framework.conf.spinner_options',
@ -87,37 +78,36 @@
hzUtils, hzUtils,
$cookieStore, $cookieStore,
$http, $http,
$cookies $cookies) {
) {
$http.defaults.headers.post['X-CSRFToken'] = $cookies.csrftoken; $http.defaults.headers.post['X-CSRFToken'] = $cookies.csrftoken;
// expose the legacy utils module // expose the legacy utils module
horizon.utils = hzUtils; horizon.utils = hzUtils;
horizon.conf.spinner_options = spinnerOptions; horizon.conf.spinner_options = spinnerOptions;
horizon.cookies = angular.extend({}, $cookieStore, { horizon.cookies = angular.extend({}, $cookieStore, {
put: put, put: put,
getRaw: getRaw getRaw: getRaw
});
// rewire the angular-gettext catalog to use django catalog
gettextCatalog.setCurrentLanguage(horizon.languageCode);
gettextCatalog.setStrings(horizon.languageCode, django.catalog);
/*
* cookies are updated at the end of current $eval, so for the horizon
* namespace we need to wrap it in a $apply function.
*/
function put(key, value) {
angular.element('body').scope().$apply(function () {
$cookieStore.put(key, value);
}); });
}
function getRaw(key) { // rewire the angular-gettext catalog to use django catalog
return $cookies[key]; gettextCatalog.setCurrentLanguage(horizon.languageCode);
gettextCatalog.setStrings(horizon.languageCode, django.catalog);
/*
* cookies are updated at the end of current $eval, so for the horizon
* namespace we need to wrap it in a $apply function.
*/
function put(key, value) {
angular.element('body').scope().$apply(function () {
$cookieStore.put(key, value);
});
}
function getRaw(key) {
return $cookies[key];
}
} }
}
}()); }());

View File

@ -22,32 +22,4 @@
}); });
}); });
describe('$locationProvider', function() {
var $locationProvider;
beforeEach(function() {
angular.module('horizon.auth', []);
angular.module('locationProviderConfig', [])
.config(function(_$locationProvider_) {
$locationProvider = _$locationProvider_;
spyOn($locationProvider, 'html5Mode').and.callThrough();
spyOn($locationProvider, 'hashPrefix').and.callThrough();
});
module('locationProviderConfig');
module('horizon.app');
inject();
});
it('should set html5 mode', function() {
expect($locationProvider.html5Mode).toHaveBeenCalledWith(true);
});
it('should set hashPrefix', function() {
expect($locationProvider.hashPrefix).toHaveBeenCalledWith('!');
});
});
})(); })();