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
bc267718
Commit
bc267718
authored
Sep 26, 2015
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for AnnotationController.{setPrivacy, hasContent}
Card 89
parent
72e1cde6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
16 deletions
+35
-16
annotation.coffee
h/static/scripts/directive/annotation.coffee
+7
-16
annotation-test.coffee
h/static/scripts/directive/test/annotation-test.coffee
+28
-0
No files found.
h/static/scripts/directive/annotation.coffee
View file @
bc267718
...
@@ -100,15 +100,6 @@ AnnotationController = [
...
@@ -100,15 +100,6 @@ AnnotationController = [
this.isPrivate = ->
this.isPrivate = ->
permissions.isPrivate model.permissions, model.user
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
# @ngdoc method
# @name annotation.AnnotationController#isShared
# @name annotation.AnnotationController#isShared
...
@@ -120,18 +111,18 @@ AnnotationController = [
...
@@ -120,18 +111,18 @@ AnnotationController = [
###
*
###
*
# @ngdoc method
# @ngdoc method
# @name annotation.AnnotationController#set
Shared
# @name annotation.AnnotationController#set
Privacy
#
#
# 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) ->
this.setPrivacy = (privacy) ->
if privacy == 'private'
if privacy == 'private'
this.setP
rivate()
model.permissions = permissions.p
rivate()
else if privacy == 'shared'
else if privacy == 'shared'
this.setShared(
)
model.permissions = permissions.public(model.group
)
###
*
###
*
# @ngdoc method
# @ngdoc method
...
...
h/static/scripts/directive/test/annotation-test.coffee
View file @
bc267718
...
@@ -179,6 +179,34 @@ describe 'annotation', ->
...
@@ -179,6 +179,34 @@ describe 'annotation', ->
controller
.
reply
()
controller
.
reply
()
assert
.
deepEqual
(
reply
.
permissions
,
{
read
:
[
'justme'
]})
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'
,
->
describe
'#render'
,
->
beforeEach
->
beforeEach
->
...
...
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