Commit bc267718 authored by Robert Knight's avatar Robert Knight

Add tests for AnnotationController.{setPrivacy, hasContent}

Card 89
parent 72e1cde6
......@@ -100,15 +100,6 @@ AnnotationController = [
this.isPrivate = ->
permissions.isPrivate model.permissions, model.user
###*
# @ngdoc method
# @name annotation.AnnotationController#setPrivate
#
# Set permissions on this annotation to private.
###
this.setPrivate = ->
model.permissions = permissions.private()
###*
# @ngdoc method
# @name annotation.AnnotationController#isShared
......@@ -120,18 +111,18 @@ AnnotationController = [
###*
# @ngdoc method
# @name annotation.AnnotationController#setShared
# @name annotation.AnnotationController#setPrivacy
#
# Set permissions on this annotation to share with the current group.
# Set the privacy settings on the annotation to a predefined
# level. The supported levels are 'private' which makes the annotation
# visible only to its creator and 'shared' which makes the annotation
# visible to everyone in the group.
###
this.setShared = ->
model.permissions = permissions.public(model.group)
this.setPrivacy = (privacy) ->
if privacy == 'private'
this.setPrivate()
model.permissions = permissions.private()
else if privacy == 'shared'
this.setShared()
model.permissions = permissions.public(model.group)
###*
# @ngdoc method
......
......@@ -179,6 +179,34 @@ describe 'annotation', ->
controller.reply()
assert.deepEqual(reply.permissions, {read: ['justme']})
describe '#setPrivacy', ->
beforeEach ->
createDirective()
it 'makes the annotation private when level is "private"', ->
controller.setPrivacy('private')
assert.deepEqual(annotation.permissions, {read: ['justme']})
it 'makes the annotation shared when level is "shared"', ->
controller.setPrivacy('shared')
assert.deepEqual(annotation.permissions, {read: ['everybody']});
describe '#hasContent', ->
beforeEach ->
createDirective()
it 'returns false if the annotation has no tags or text', ->
controller.annotation.text = ''
controller.annotation.tags = [];
assert.ok(!controller.hasContent())
it 'returns true if the annotation has tags or text', ->
controller.annotation.text = 'bar'
assert.ok(controller.hasContent())
controller.annotation.text = ''
controller.annotation.tags = [{text: 'foo'}]
assert.ok(controller.hasContent())
describe '#render', ->
beforeEach ->
......
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