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
2cae4fe8
Commit
2cae4fe8
authored
Dec 10, 2015
by
Sean Hammond
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2786 from hypothesis/fix-standalone-reply-pages
Fix standalone reply pages
parents
84a34b21
fe0250ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
27 deletions
+26
-27
annotation-viewer-controller.coffee
h/static/scripts/annotation-viewer-controller.coffee
+5
-6
annotation-viewer-controller-test.coffee
...tic/scripts/test/annotation-viewer-controller-test.coffee
+21
-21
No files found.
h/static/scripts/annotation-viewer-controller.coffee
View file @
2cae4fe8
...
...
@@ -19,14 +19,13 @@ module.exports = class AnnotationViewerController
$scope
.
search
.
update
=
(
query
)
->
$location
.
path
(
'/stream'
).
search
(
'q'
,
query
)
search_params
=
{
_id
:
id
,
_separate_replies
:
true
}
store
.
SearchResource
.
get
(
search_params
,
({
rows
,
replies
})
->
annotationMapper
.
loadAnnotations
(
rows
,
replies
)
store
.
AnnotationResource
.
get
({
id
:
id
},
(
annotation
)
->
annotationMapper
.
loadAnnotations
([
annotation
])
$scope
.
threadRoot
=
{
children
:
[
threading
.
idTable
[
id
]]}
)
store
.
SearchResource
.
get
({
references
:
id
},
({
rows
})
->
annotationMapper
.
loadAnnotations
(
rows
)
)
streamFilter
.
setMatchPolicyIncludeAny
()
...
...
h/static/scripts/test/annotation-viewer-controller-test.coffee
View file @
2cae4fe8
...
...
@@ -33,7 +33,9 @@ describe "AnnotationViewerController", ->
}
streamer
:
streamer
or
{
setConfig
:
->
}
store
:
store
or
{
SearchResource
:
{
get
:
sinon
.
spy
()}}
AnnotationResource
:
{
get
:
sinon
.
spy
()}
SearchResource
:
{
get
:
sinon
.
spy
()}
}
streamFilter
:
streamFilter
or
{
setMatchPolicyIncludeAny
:
->
{
addClause
:
->
{
addClause
:
->
}}
getFilter
:
->
...
...
@@ -45,31 +47,29 @@ describe "AnnotationViewerController", ->
"AnnotationViewerController"
,
locals
)
return
locals
it
"calls the search API to get the annotation and its replies"
,
->
it
"fetches the top-level annotation"
,
->
{
store
}
=
createAnnotationViewerController
({})
assert
.
calledOnce
(
store
.
AnnotationResource
.
get
)
assert
.
calledWith
(
store
.
AnnotationResource
.
get
,
{
id
:
"test_annotation_id"
})
it
"fetches any replies referencing the top-level annotation"
,
->
{
store
}
=
createAnnotationViewerController
({})
assert
store
.
SearchResource
.
get
.
calledOnce
assert
store
.
SearchResource
.
get
.
calledWith
(
{
_id
:
"test_annotation_id"
,
_separate_replies
:
true
})
assert
.
calledOnce
(
store
.
SearchResource
.
get
)
assert
.
calledWith
(
store
.
SearchResource
.
get
,
{
references
:
"test_annotation_id"
})
it
"loads the top-level annotation and replies into annotationMapper"
,
->
{
annotationMapper
}
=
createAnnotationViewerController
({})
it
"passes the annotations and replies from search into loadAnnotations"
,
->
getAnnotation
=
sinon
.
stub
().
callsArgWith
(
1
,
{
id
:
'foo'
})
getReferences
=
sinon
.
stub
().
callsArgWith
(
1
,
{
rows
:
[{
id
:
'bar'
},
{
id
:
'baz'
}]})
{
annotationMapper
}
=
createAnnotationViewerController
({
store
:
{
SearchResource
:
{
# SearchResource.get(id, func) takes an annotation id and a function
# that it should call with the search result. Our mock .get() here
# just immediately calls the function with some fake results.
get
:
(
id
,
func
)
->
func
(
{
# In production these would be annotation objects, not strings.
rows
:
[
'annotation_1'
,
'annotation_2'
]
replies
:
[
'reply_1'
,
'reply_2'
,
'reply_3'
]
}
)
}
AnnotationResource
:
{
get
:
getAnnotation
}
SearchResource
:
{
get
:
getReferences
}
}
})
assert
annotationMapper
.
loadAnnotations
.
calledWith
(
[
'annotation_1'
,
'annotation_2'
],
[
'reply_1'
,
'reply_2'
,
'reply_3'
]
),
"It should pass all the annotations and replies to loadAnnotations()"
assert
.
calledWith
(
annotationMapper
.
loadAnnotations
,
[{
id
:
'foo'
}])
assert
.
calledWith
(
annotationMapper
.
loadAnnotations
,
[{
id
:
'bar'
},
{
id
:
'baz'
}])
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