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
0c2faf3f
Commit
0c2faf3f
authored
Dec 19, 2014
by
Gergely Ujvari
Committed by
ujvari
Jan 15, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce isPrivate for permissions service
parent
a807c8e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
annotation.coffee
h/static/scripts/directives/annotation.coffee
+1
-1
permissions-service.coffee
h/static/scripts/permissions-service.coffee
+12
-0
permissions-service-test.coffee
tests/js/permissions-service-test.coffee
+16
-0
No files found.
h/static/scripts/directives/annotation.coffee
View file @
0c2faf3f
...
...
@@ -82,7 +82,7 @@ AnnotationController = [
# @returns {boolean} True if the annotation is private to the current user.
###
this.isPrivate = ->
model.user and angular.equals(model.permissions?.read or [], [model.user])
permissions.isPrivate model.permissions, model.user
###
*
# @ngdoc method
...
...
h/static/scripts/permissions-service.coffee
View file @
0c2faf3f
...
...
@@ -53,6 +53,18 @@ class Permissions
isPublic: (permissions) ->
GROUP_WORLD in (permissions?.read or [])
###
*
# @ngdoc method
# @name permissions#isPrivate
#
# @param {Object} permissions
# @param {String} user
#
# @returns {boolean} True if the annotation is private to the user.
###
isPrivate: (permissions, user) ->
user and angular.equals(permissions?.read or [], [user])
###
*
# @ngdoc method
# @name permissions#permits
...
...
tests/js/permissions-service-test.coffee
View file @
0c2faf3f
...
...
@@ -58,6 +58,22 @@ describe 'h', ->
permission
.
read
=
[
'one'
,
'two'
,
'three'
]
assert
.
isFalse
(
permissions
.
isPublic
(
permission
))
describe
'isPrivate'
,
->
it
'returns true if the given user is in the permissions'
,
->
user
=
'acct:angry@birds.com'
permission
=
{
read
:
[
user
]}
assert
.
isTrue
(
permissions
.
isPrivate
(
permission
,
user
))
it
'returns false if another user is in the permissions'
,
->
users
=
[
'acct:angry@birds.com'
,
'acct:angry@joe.com'
]
permission
=
{
read
:
users
}
assert
.
isFalse
(
permissions
.
isPrivate
(
permission
,
'acct:angry@birds.com'
))
it
'returns false if different user in the permissions'
,
->
user
=
'acct:angry@joe.com'
permission
=
{
read
:
[
'acct:angry@birds.com'
]}
assert
.
isFalse
(
permissions
.
isPrivate
(
permission
,
user
))
describe
'permits'
,
->
it
'returns true when annotation has no permissions'
,
->
annotation
=
{}
...
...
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