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
Hide 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
annotationMapper
.
loadAnnotations
data
when
'delete'
for
annotation
in
data
$scope
.
$emit
(
'annotationDeleted'
,
annotation
)
if
a
=
threading
.
idTable
[
annotation
.
id
]
?
.
message
$scope
.
$emit
(
'annotationDeleted'
,
a
)
streamer
.
onmessage
=
(
data
)
->
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
describe
'h'
,
->
$scope
=
null
fakeAnnotationMapper
=
null
fakeIdentity
=
null
fakeLocation
=
null
fakeParams
=
null
...
...
@@ -10,6 +11,7 @@ describe 'h', ->
fakeStore
=
SearchResource
:
get
:
sinon
.
spy
()
fakeThreading
=
null
sandbox
=
null
...
...
@@ -35,10 +37,18 @@ describe 'h', ->
send
:
sandbox
.
spy
()
}
fakeAnnotationMapper
=
loadAnnotations
:
sandbox
.
spy
()
fakeThreading
=
idTable
:
{}
$provide
.
value
'identity'
,
fakeIdentity
$provide
.
value
'streamer'
,
fakeStreamer
$provide
.
value
'$location'
,
fakeLocation
$provide
.
value
'$routeParams'
,
fakeParams
$provide
.
value
'annotationMapper'
,
fakeAnnotationMapper
$provide
.
value
'threading'
,
fakeThreading
return
afterEach
->
...
...
@@ -49,6 +59,7 @@ describe 'h', ->
beforeEach
inject
(
$controller
,
$rootScope
)
->
$scope
=
$rootScope
.
$new
()
$scope
.
$digest
=
sinon
.
spy
()
createController
=
->
$controller
(
'AppController'
,
{
$scope
:
$scope
})
...
...
@@ -57,6 +68,61 @@ describe 'h', ->
createController
()
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'
,
->
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