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
e009194e
Commit
e009194e
authored
Feb 22, 2015
by
gergely-ujvari
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1949 from hypothesis/1928-fix-realtime-delete
Fix real-time delete
parents
620c50b5
56de2455
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
1 deletion
+68
-1
controllers.coffee
h/static/scripts/controllers.coffee
+2
-1
controllers-test.coffee
tests/js/controllers-test.coffee
+66
-0
No files found.
h/static/scripts/controllers.coffee
View file @
e009194e
...
@@ -48,7 +48,8 @@ class AppController
...
@@ -48,7 +48,8 @@ class AppController
annotationMapper
.
loadAnnotations
data
annotationMapper
.
loadAnnotations
data
when
'delete'
when
'delete'
for
annotation
in
data
for
annotation
in
data
$scope
.
$emit
(
'annotationDeleted'
,
annotation
)
if
a
=
threading
.
idTable
[
annotation
.
id
]
?
.
message
$scope
.
$emit
(
'annotationDeleted'
,
a
)
streamer
.
onmessage
=
(
data
)
->
streamer
.
onmessage
=
(
data
)
->
return
if
!
data
or
data
.
type
!=
'annotation-notification'
return
if
!
data
or
data
.
type
!=
'annotation-notification'
...
...
tests/js/controllers-test.coffee
View file @
e009194e
...
@@ -3,6 +3,7 @@ sinon.assert.expose assert, prefix: null
...
@@ -3,6 +3,7 @@ sinon.assert.expose assert, prefix: null
describe
'h'
,
->
describe
'h'
,
->
$scope
=
null
$scope
=
null
fakeAnnotationMapper
=
null
fakeIdentity
=
null
fakeIdentity
=
null
fakeLocation
=
null
fakeLocation
=
null
fakeParams
=
null
fakeParams
=
null
...
@@ -10,6 +11,7 @@ describe 'h', ->
...
@@ -10,6 +11,7 @@ describe 'h', ->
fakeStore
=
fakeStore
=
SearchResource
:
SearchResource
:
get
:
sinon
.
spy
()
get
:
sinon
.
spy
()
fakeThreading
=
null
sandbox
=
null
sandbox
=
null
...
@@ -35,10 +37,18 @@ describe 'h', ->
...
@@ -35,10 +37,18 @@ describe 'h', ->
send
:
sandbox
.
spy
()
send
:
sandbox
.
spy
()
}
}
fakeAnnotationMapper
=
loadAnnotations
:
sandbox
.
spy
()
fakeThreading
=
idTable
:
{}
$provide
.
value
'identity'
,
fakeIdentity
$provide
.
value
'identity'
,
fakeIdentity
$provide
.
value
'streamer'
,
fakeStreamer
$provide
.
value
'streamer'
,
fakeStreamer
$provide
.
value
'$location'
,
fakeLocation
$provide
.
value
'$location'
,
fakeLocation
$provide
.
value
'$routeParams'
,
fakeParams
$provide
.
value
'$routeParams'
,
fakeParams
$provide
.
value
'annotationMapper'
,
fakeAnnotationMapper
$provide
.
value
'threading'
,
fakeThreading
return
return
afterEach
->
afterEach
->
...
@@ -49,6 +59,7 @@ describe 'h', ->
...
@@ -49,6 +59,7 @@ describe 'h', ->
beforeEach
inject
(
$controller
,
$rootScope
)
->
beforeEach
inject
(
$controller
,
$rootScope
)
->
$scope
=
$rootScope
.
$new
()
$scope
=
$rootScope
.
$new
()
$scope
.
$digest
=
sinon
.
spy
()
createController
=
->
createController
=
->
$controller
(
'AppController'
,
{
$scope
:
$scope
})
$controller
(
'AppController'
,
{
$scope
:
$scope
})
...
@@ -57,6 +68,61 @@ describe 'h', ->
...
@@ -57,6 +68,61 @@ describe 'h', ->
createController
()
createController
()
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
assert
.
isFalse
(
$scope
.
dialog
.
visible
)
describe
'applyUpdate'
,
->
it
'calls annotationMapper.loadAnnotations() upon "create" action'
,
->
createController
()
anns
=
[
"my"
,
"annotations"
]
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"create"
payload
:
anns
assert
.
calledWith
fakeAnnotationMapper
.
loadAnnotations
,
anns
it
'calls annotationMapper.loadAnnotations() upon "update" action'
,
->
createController
()
anns
=
[
"my"
,
"annotations"
]
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"update"
payload
:
anns
assert
.
calledWith
fakeAnnotationMapper
.
loadAnnotations
,
anns
it
'calls annotationMapper.loadAnnotations() upon "past" action'
,
->
createController
()
anns
=
[
"my"
,
"annotations"
]
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"past"
payload
:
anns
assert
.
calledWith
fakeAnnotationMapper
.
loadAnnotations
,
anns
it
'looks up annotations at threading upon "delete" action'
,
->
createController
()
$scope
.
$emit
=
sinon
.
spy
()
# Prepare the annotation that will come "from the wire"
anns
=
[
id
:
"fakeId"
data
:
"remote data"
]
# Prepare the annotation that we have locally
localAnnotation
=
id
:
"fake it"
data
:
"local data"
# Put our annotation into the threading id table
fakeThreading
.
idTable
.
fakeId
=
message
:
localAnnotation
# Simulate a delete action
fakeStreamer
.
onmessage
type
:
"annotation-notification"
options
:
action
:
"delete"
payload
:
anns
assert
.
calledWith
$scope
.
$emit
,
"annotationDeleted"
,
localAnnotation
describe
'AnnotationViewerController'
,
->
describe
'AnnotationViewerController'
,
->
annotationViewer
=
null
annotationViewer
=
null
...
...
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