Cross Reference:
xref
: /
ontohub
/
test
/
unit
/
team_user_test.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
team_user_test.rb revision c622fbf3120c732e74ab43bb0457388b477e6898
1494
N/A
require
'test_helper'
1494
N/A
1494
N/A
class
TeamUserTest
<
ActiveSupport
::
TestCase
1494
N/A
context
'Associations'
do
1494
N/A
should
belong_to
:
team
1494
N/A
should
belong_to
:
user
1494
N/A
should
belong_to
:
creator
1494
N/A
end
1494
N/A
1494
N/A
context
'team with admin and user'
do
1494
N/A
setup
do
1494
N/A
@
team_admin
=
Factory
:
user
# admin in team
1494
N/A
@
team_user
=
Factory
:
user
# non-admin in team
1494
N/A
1494
N/A
@
admin_user
=
Factory
:
team_user
, :
user
=> @
team_admin
1494
N/A
@
team
= @
admin_user.team
1494
N/A
1494
N/A
@
team.users
<< @
team_user
1494
N/A
@
non_admim_user
= @
team.team_users.non_admin.first
1494
N/A
end
1494
N/A
1494
N/A
should
'have 2 members'
do
1494
N/A
assert_equal
2
, @
team.team_users.count
1494
N/A
end
1494
N/A
1494
N/A
should
'have a admin'
do
1494
N/A
assert_equal
@
team_admin
, @
team.team_users.admin.first.user
1494
N/A
end
1494
N/A
1494
N/A
should
'have a non-admin'
do
1494
N/A
assert_equal
@
team_user
, @
team.team_users.non_admin.first.user
1494
N/A
end
1494
N/A
1494
N/A
should
'remove non-admin'
do
1494
N/A
assert
@
non_admim_user.destroy
1494
N/A
end
1494
N/A
1494
N/A
should
'not destroy the last admin'
do
1512
N/A
assert_raises
Permission
::
PowerVaccuumError
do
1512
N/A
assert
@
admin_user.destroy
1494
N/A
end
1494
N/A
end
1494
N/A
1494
N/A
should
'not remove the last admin flag'
do
1494
N/A
assert_raises
Permission
::
PowerVaccuumError
do
1494
N/A
@
admin_user.update
_attribute
:
admin
,
false
1494
N/A
end
1494
N/A
end
1494
N/A
end
1494
N/A
end
1494
N/A