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
874fb132
Commit
874fb132
authored
May 14, 2015
by
Randall Leeds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On save, show a generic error for unavailability
parent
fedf587b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
annotation.coffee
h/static/scripts/directive/annotation.coffee
+8
-4
annotation-test.coffee
h/static/scripts/directive/test/annotation-test.coffee
+26
-0
No files found.
h/static/scripts/directive/annotation.coffee
View file @
874fb132
...
...
@@ -13,10 +13,14 @@ validate = (value) ->
# Return an error message based on a server response.
errorMessage
=
(
reason
)
->
if
reason
.
status
is
0
message
=
"Service unreachable."
else
message
=
reason
.
status
+
" "
+
reason
.
statusText
if
reason
.
data
.
reason
message
=
message
+
": "
+
reason
.
data
.
reason
message
return
message
###*
...
...
h/static/scripts/directive/test/annotation-test.coffee
View file @
874fb132
...
...
@@ -412,6 +412,16 @@ describe 'annotation', ->
window
.
confirm
.
returns
(
false
)
assert
fakeAnnotationMapper
.
deleteAnnotation
.
notCalled
it
"flashes a generic error if the server cannot be reached"
,
->
window
.
confirm
.
returns
(
true
)
fakeAnnotationMapper
.
deleteAnnotation
.
returns
(
Promise
.
reject
({
status
:
0
}))
controller
.
delete
().
then
(
->
assert
fakeFlash
.
error
.
calledWith
(
"Service unreachable."
,
"Saving annotation failed"
)
)
$timeout
.
flush
()
it
"flashes an error if the delete fails on the server"
,
->
window
.
confirm
.
returns
(
true
)
fakeAnnotationMapper
.
deleteAnnotation
.
returns
(
Promise
.
reject
({
...
...
@@ -448,6 +458,14 @@ describe 'annotation', ->
assert
$rootScope
.
$emit
.
calledWith
(
"annotationCreated"
)
)
it
"flashes a generic error if the server cannot be reached"
,
->
annotation
.
$create
.
returns
(
Promise
.
reject
({
status
:
0
}))
controller
.
save
().
then
(
->
assert
fakeFlash
.
error
.
calledWith
(
"Service unreachable."
,
"Saving annotation failed"
)
)
it
"flashes an error if saving the annotation fails on the server"
,
->
annotation
.
$create
.
returns
(
Promise
.
reject
({
status
:
500
,
...
...
@@ -474,6 +492,14 @@ describe 'annotation', ->
controller
.
action
=
'edit'
annotation
.
$update
=
sandbox
.
stub
()
it
"flashes a generic error if the server cannot be reached"
,
->
annotation
.
$update
.
returns
(
Promise
.
reject
({
status
:
0
}))
controller
.
save
().
then
(
->
assert
fakeFlash
.
error
.
calledWith
(
"Service unreachable."
,
"Saving annotation failed"
)
)
it
"flashes an error if saving the annotation fails on the server"
,
->
annotation
.
$update
.
returns
(
Promise
.
reject
({
status
:
500
,
...
...
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