Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
02010ce2
Commit
02010ce2
authored
Apr 19, 2016
by
Christof Dorner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3210 from hypothesis/check-session-response
Fix error in session.js when an /app request fails
parents
15d6d3fb
637c7d8b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
32 deletions
+55
-32
app.js
h/static/scripts/app.js
+27
-24
session.js
h/static/scripts/session.js
+5
-2
session-test.js
h/static/scripts/test/session-test.js
+23
-6
No files found.
h/static/scripts/app.js
View file @
02010ce2
...
@@ -28,30 +28,33 @@ if (settings.raven) {
...
@@ -28,30 +28,33 @@ if (settings.raven) {
var
mail
=
require
(
'./vendor/jwz'
);
var
mail
=
require
(
'./vendor/jwz'
);
var
streamer
=
require
(
'./streamer'
);
var
streamer
=
require
(
'./streamer'
);
var
resolve
=
// Fetch external state that the app needs before it can run. This includes the
// Ensure that we have available a) the current authenticated userid, and b)
// authenticated user state, the API endpoint URLs and WebSocket connection.
// the list of user groups.
var
resolve
=
{
{
// @ngInject
sessionState
:
[
'session'
,
function
(
session
)
{
return
session
.
load
();
}],
sessionState
:
function
(
session
)
{
store
:
[
'store'
,
function
(
store
)
{
return
store
.
$promise
;
}],
return
session
.
load
();
streamer
:
streamer
.
connect
,
},
threading
:
[
// @ngInject
'annotationMapper'
,
'drafts'
,
'threading'
,
store
:
function
(
store
)
{
function
(
annotationMapper
,
drafts
,
threading
)
{
return
store
.
$promise
;
// Unload all the annotations
},
annotationMapper
.
unloadAnnotations
(
threading
.
annotationList
());
streamer
:
streamer
.
connect
,
// @ngInject
// Reset the threading root
threading
:
function
(
annotationMapper
,
drafts
,
threading
)
{
threading
.
createIdTable
([]);
// Unload all the annotations
threading
.
root
=
mail
.
messageContainer
();
annotationMapper
.
unloadAnnotations
(
threading
.
annotationList
());
// Reload all new, unsaved annotations
// Reset the threading root
threading
.
thread
(
drafts
.
unsaved
());
threading
.
createIdTable
([]);
threading
.
root
=
mail
.
messageContainer
();
return
threading
;
}
// Reload all new, unsaved annotations
]
threading
.
thread
(
drafts
.
unsaved
());
};
return
threading
;
},
};
// @ngInject
// @ngInject
function
configureLocation
(
$locationProvider
)
{
function
configureLocation
(
$locationProvider
)
{
...
...
h/static/scripts/session.js
View file @
02010ce2
...
@@ -154,8 +154,11 @@ function session($http, $resource, $rootScope, flash, raven, settings) {
...
@@ -154,8 +154,11 @@ function session($http, $resource, $rootScope, flash, raven, settings) {
return
model
;
return
model
;
};
};
function
process
(
data
)
{
function
process
(
data
,
headersGetter
,
status
)
{
// Parse as json
if
(
status
<
200
||
status
>=
500
)
{
return
;
}
data
=
angular
.
fromJson
(
data
);
data
=
angular
.
fromJson
(
data
);
// Lift response data
// Lift response data
...
...
h/static/scripts/test/session-test.js
View file @
02010ce2
"use strict"
;
"use strict"
;
var
mock
=
angular
.
mock
;
var
angular
=
require
(
'angular'
)
;
var
events
=
require
(
'../events'
);
var
events
=
require
(
'../events'
);
var
mock
=
angular
.
mock
;
describe
(
'h:session'
,
function
()
{
describe
(
'h:session'
,
function
()
{
var
$httpBackend
;
var
$httpBackend
;
var
$rootScope
;
var
$rootScope
;
var
fakeFlash
;
var
fakeFlash
;
var
fakeRaven
;
var
fakeRaven
;
var
fakeXsrf
;
var
sandbox
;
var
sandbox
;
var
session
;
var
session
;
...
@@ -50,7 +51,7 @@ describe('h:session', function () {
...
@@ -50,7 +51,7 @@ describe('h:session', function () {
// There's little point testing every single route here, as they're
// There's little point testing every single route here, as they're
// declarative and ultimately we'd be testing ngResource.
// declarative and ultimately we'd be testing ngResource.
describe
(
'
.
login()'
,
function
()
{
describe
(
'
#
login()'
,
function
()
{
var
url
=
'https://test.hypothes.is/app?__formid__=login'
;
var
url
=
'https://test.hypothes.is/app?__formid__=login'
;
it
(
'should send an HTTP POST to the action'
,
function
()
{
it
(
'should send an HTTP POST to the action'
,
function
()
{
...
@@ -129,7 +130,7 @@ describe('h:session', function () {
...
@@ -129,7 +130,7 @@ describe('h:session', function () {
});
});
});
});
describe
(
'
.
load()'
,
function
()
{
describe
(
'
#
load()'
,
function
()
{
var
url
=
'https://test.hypothes.is/app'
;
var
url
=
'https://test.hypothes.is/app'
;
it
(
'should fetch the session data'
,
function
()
{
it
(
'should fetch the session data'
,
function
()
{
...
@@ -157,9 +158,25 @@ describe('h:session', function () {
...
@@ -157,9 +158,25 @@ describe('h:session', function () {
session
.
load
();
session
.
load
();
$httpBackend
.
flush
();
$httpBackend
.
flush
();
});
});
var
failedRequestCases
=
[{
status
:
-
1
,
body
:
null
,
},{
status
:
504
,
body
:
'Gateway Timeout'
,
}];
failedRequestCases
.
forEach
(
function
(
testCase
)
{
it
(
'should tolerate failed requests'
,
function
()
{
$httpBackend
.
expectGET
(
url
).
respond
(
testCase
.
status
,
testCase
.
body
);
session
.
load
();
$httpBackend
.
flush
();
});
});
});
});
describe
(
'
.
update()'
,
function
()
{
describe
(
'
#
update()'
,
function
()
{
it
(
'broadcasts SESSION_CHANGED when the session changes'
,
function
()
{
it
(
'broadcasts SESSION_CHANGED when the session changes'
,
function
()
{
var
sessionChangeCallback
=
sinon
.
stub
();
var
sessionChangeCallback
=
sinon
.
stub
();
...
@@ -220,7 +237,7 @@ describe('h:session', function () {
...
@@ -220,7 +237,7 @@ describe('h:session', function () {
});
});
});
});
describe
(
'
.
dismiss_sidebar_tutorial()'
,
function
()
{
describe
(
'
#
dismiss_sidebar_tutorial()'
,
function
()
{
var
url
=
'https://test.hypothes.is/app/dismiss_sidebar_tutorial'
;
var
url
=
'https://test.hypothes.is/app/dismiss_sidebar_tutorial'
;
it
(
'disables the tutorial for the user'
,
function
()
{
it
(
'disables the tutorial for the user'
,
function
()
{
$httpBackend
.
expectPOST
(
url
).
respond
({});
$httpBackend
.
expectPOST
(
url
).
respond
({});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment