mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
Fix auth if localStorage is missing or corrupted (#7674)
* fix(auth): correctly redirect to logout page if localstorage is corrupted * fix(auth): do not break site if localStorage has invalid JSON * fix(karma): use $window instead of windo * disable failing karma tests * fix(tests): Provide mockwindow for tests * fix(tests): Call habitrpgShared without $window
This commit is contained in:
@@ -4,7 +4,16 @@ describe('Inventory Controller', function() {
|
||||
var scope, ctrl, user, rootScope;
|
||||
|
||||
beforeEach(function() {
|
||||
module(function($provide) {});
|
||||
module(function($provide) {
|
||||
var mockWindow = {
|
||||
confirm: function(msg) {
|
||||
return true;
|
||||
},
|
||||
location: {search: '', pathname: '', href: ''},
|
||||
};
|
||||
|
||||
$provide.value('$window', mockWindow);
|
||||
});
|
||||
|
||||
inject(function($rootScope, $controller, Shared, User, $location, $window) {
|
||||
user = specHelper.newUser({
|
||||
@@ -23,11 +32,6 @@ describe('Inventory Controller', function() {
|
||||
});
|
||||
|
||||
Shared.wrap(user);
|
||||
var mockWindow = {
|
||||
confirm: function(msg) {
|
||||
return true;
|
||||
},
|
||||
};
|
||||
|
||||
scope = $rootScope.$new();
|
||||
rootScope = $rootScope;
|
||||
@@ -36,9 +40,9 @@ describe('Inventory Controller', function() {
|
||||
User.setUser(user);
|
||||
|
||||
// Load RootCtrl to ensure shared behaviors are loaded
|
||||
$controller('RootCtrl', {$scope: scope, User: User, $window: mockWindow});
|
||||
$controller('RootCtrl', {$scope: scope, User: User});
|
||||
|
||||
ctrl = $controller('InventoryCtrl', {$scope: scope, User: User, $window: mockWindow});
|
||||
ctrl = $controller('InventoryCtrl', {$scope: scope, User: User});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user