Commit 313754ec authored by Nick Stenning's avatar Nick Stenning

Merge pull request #2300 from hypothesis/nipsa

Add support for flagging user accounts as "not in public site areas"
parents d5411690 a2040d37
...@@ -24,8 +24,8 @@ module.exports = class AnnotationViewerController ...@@ -24,8 +24,8 @@ module.exports = class AnnotationViewerController
$location.path('/stream').search('q', query) $location.path('/stream').search('q', query)
id = $routeParams.id id = $routeParams.id
store.SearchResource.get _id: id, ({rows}) -> store.AnnotationResource.read id: id, (annotation) ->
annotationMapper.loadAnnotations(rows) annotationMapper.loadAnnotations([annotation])
$scope.threadRoot = children: [$scope.threading.getContainer(id)] $scope.threadRoot = children: [$scope.threading.getContainer(id)]
store.SearchResource.get references: id, ({rows}) -> store.SearchResource.get references: id, ({rows}) ->
annotationMapper.loadAnnotations(rows) annotationMapper.loadAnnotations(rows)
......
{module, inject} = require('angular-mock') {inject, module} = require('angular-mock')
assert = chai.assert assert = chai.assert
sinon.assert.expose assert, prefix: null
describe "AnnotationViewerController", ->
describe 'AnnotationViewerController', ->
annotationViewerController = null
before -> before ->
angular.module('h', ['ngRoute']) angular.module("h", [])
.controller('AnnotationViewerController', require('../annotation-viewer-controller')) .controller(
'AnnotationViewerController',
require('../annotation-viewer-controller'))
beforeEach(module("h"))
beforeEach inject ($controller, $rootScope) -> # Return the $controller service from Angular.
$scope = $rootScope.$new() getControllerService = ->
$scope.search = {} $controller = null
annotationViewerController = $controller 'AnnotationViewerController', inject((_$controller_) ->
$scope: $scope $controller = _$controller_
)
return $controller
it 'sets the isEmbedded property to false', -> # Return a new AnnotationViewerController instance.
createAnnotationViewerController = ({$location, $routeParams, $scope,
streamer, store, streamFilter,
annotationMapper}) ->
locals = {
$location: $location or {}
$routeParams: $routeParams or {id: "test_annotation_id"}
$scope: $scope or {search: {}}
streamer: streamer or {send: ->}
store: store or {
AnnotationResource: {read: sinon.spy()},
SearchResource: {get: ->}}
streamFilter: streamFilter or {
setMatchPolicyIncludeAny: -> {addClause: -> {addClause: ->}}
getFilter: ->
}
annotationMapper: annotationMapper or {loadAnnotations: sinon.spy()}
}
locals["ctrl"] = getControllerService()(
"AnnotationViewerController", locals)
return locals
it "sets the isEmbedded property to false", ->
{$scope} = createAnnotationViewerController({})
assert.isFalse($scope.isEmbedded) assert.isFalse($scope.isEmbedded)
it "calls the annotation API to get the annotation", ->
{store} = createAnnotationViewerController({})
assert store.AnnotationResource.read.args[0][0].id == "test_annotation_id"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment