Cross Reference:
xref
: /
ontohub
/
test
/
unit
/
permission_test.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
permission_test.rb revision c622fbf3120c732e74ab43bb0457388b477e6898
70
N/A
require
'test_helper'
70
N/A
286
N/A
class
PermissionTest
<
ActiveSupport
::
TestCase
70
N/A
70
N/A
should
belong_to
:
creator
70
N/A
should
belong_to
:
item
70
N/A
should
belong_to
:
subject
70
N/A
70
N/A
[
'owner'
,
'editor'
].
each
do
|
val
|
70
N/A
should
allow_value
(
val
)
.
for
:
role
70
N/A
end
70
N/A
70
N/A
[
nil
,
''
,
'foo'
].
each
do
|
val
|
70
N/A
should_not
allow_value
(
val
)
.
for
:
role
70
N/A
end
70
N/A
70
N/A
context
'Ontology'
do
70
N/A
setup
do
70
N/A
@
ontology
=
Factory
:
ontology
70
N/A
end
70
N/A
70
N/A
context
'admin user'
do
70
N/A
setup
do
70
N/A
@
admin
=
Factory
:
admin
70
N/A
end
70
N/A
70
N/A
should
'have owner and editor permissions'
do
70
N/A
assert
@
ontology.permission
?
(:
owner
, @
admin
)
70
N/A
assert
@
ontology.permission
?
(:
editor
, @
admin
)
70
N/A
end
356
N/A
end
70
N/A
70
N/A
context
'owner user'
do
70
N/A
setup
do
98
N/A
@
permission
=
Factory
:
permission
,
item
: @
ontology
321
N/A
end
321
N/A
213
N/A
should
'have owner and editor permissions'
do
304
N/A
assert
@
ontology.permission
?
(:
owner
, @
permission.subject
)
325
N/A
assert
@
ontology.permission
?
(:
editor
, @
permission.subject
)
320
N/A
end
332
N/A
end
231
N/A
98
N/A
context
'editor user'
do
347
N/A
setup
do
346
N/A
@
permission
=
Factory
:
permission
,
item
: @
ontology
,
role
:
'editor'
324
N/A
end
347
N/A
310
N/A
should
'have editor permission'
do
316
N/A
assert
@
ontology.permission
?
(:
editor
, @
permission.subject
)
290
N/A
end
332
N/A
end
332
N/A
332
N/A
context
'team user'
do
210
N/A
setup
do
128
N/A
@
team_user
=
Factory
:
team_user
326
N/A
@
permission
=
Factory
:
permission
,
item
: @
ontology
,
subject
: @
team_user.team
335
N/A
end
70
N/A
294
N/A
should
'have owner and editor permissions'
do
98
N/A
assert
@
ontology.permission
?
(:
owner
, @
team_user.user
)
277
N/A
assert
@
ontology.permission
?
(:
editor
, @
team_user.user
)
356
N/A
end
289
N/A
end
326
N/A
290
N/A
context
'bernd'
do
286
N/A
should
'not have any permissions'
do
90
N/A
assert
!@
ontology.permission
?
(:
owner
,
nil
)
295
N/A
assert
!@
ontology.permission
?
(:
editor
,
nil
)
70
N/A
end
299
N/A
end
262
N/A
277
N/A
context
'editor'
do
332
N/A
setup
do
332
N/A
@
permission
=
Factory
:
permission
,
item
: @
ontology
,
role
:
'editor'
70
N/A
end
70
N/A
319
N/A
should
'not have owner permission'
do
280
N/A
assert
!@
ontology.permission
?
(:
owner
, @
permission.subject
)
319
N/A
end
70
N/A
end
70
N/A
98
N/A
context
'user on other team'
do
98
N/A
setup
do
231
N/A
@
team_user
=
Factory
:
team_user
98
N/A
@
permission
=
Factory
:
permission
,
item
: @
ontology
156
N/A
end
156
N/A
98
N/A
should
'not have owner and editor permissions'
do
70
N/A
assert
!@
ontology.permission
?
(:
owner
, @
team_user.user
)
70
N/A
assert
!@
ontology.permission
?
(:
editor
, @
team_user.user
)
70
N/A
end
70
N/A
end
70
N/A
70
N/A
context
'some user'
do
70
N/A
setup
do
70
N/A
@
user
=
Factory
:
user
70
N/A
end
70
N/A
70
N/A
should
'not have permissions without ontology having permissions'
do
70
N/A
assert
!@
ontology.permission
?
(:
owner
, @
user
)
70
N/A
assert
!@
ontology.permission
?
(:
editor
, @
user
)
70
N/A
end
70
N/A
end
70
N/A
end
70
N/A
end
70
N/A