Cross Reference:
xref
: /
ontohub
/
test
/
functional
/
team_users_controller_test.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
team_users_controller_test.rb revision 0b611cf877554b1aa910fa23099220f2d1d15e89
58
N/A
require
'test_helper'
58
N/A
58
N/A
class
TeamUsersControllerTest
<
ActionController
::
TestCase
58
N/A
58
N/A
should_map_nested_resources
:
teams
, :
team_users
,
58
N/A
:
as
=>
'users'
,
58
N/A
:
except
=> [:
new
, :
show
, :
edit
, :
delete
]
58
N/A
58
N/A
context
'teams'
do
58
N/A
setup
do
58
N/A
@
admin
=
FactoryGirl.create
:
user
# team admin
58
N/A
@
user
=
FactoryGirl.create
:
user
58
N/A
@
team
=
FactoryGirl.create
:
team
,
58
N/A
:
admin_user
=> @
admin
58
N/A
end
58
N/A
58
N/A
context
'on GET to index'
do
58
N/A
context
'as admin'
do
830
N/A
setup
do
58
N/A
sign_in
@
admin
58
N/A
get
:
index
, :
team_id
=> @
team.to
_param
58
N/A
end
850
N/A
58
N/A
should
render_template
'relation_list/_relation_list'
830
N/A
should
render_template
:
index
850
N/A
should
respond_with
:
success
830
N/A
end
58
N/A
128
N/A
context
'as user'
do
58
N/A
setup
do
128
N/A
sign_in
@
user
58
N/A
get
:
index
, :
team_id
=> @
team.to
_param
850
N/A
end
58
N/A
should
set_the_flash.to
(/
not
authorized
/)
58
N/A
should
redirect_to
(
"root path"
)
{ :
root
}
58
N/A
end
58
N/A
end
892
N/A
850
N/A
context
'adding a user'
do
850
N/A
context
'by admin'
do
850
N/A
setup
do
867
N/A
sign_in
@
admin
850
N/A
xhr
:
post
, :
create
,
850
N/A
:
team_id
=> @
team.id
,
850
N/A
:
team_user
=> {:
user_id
=> @
user.id
}
850
N/A
end
58
N/A
874
N/A
should
render_template
'team_users/_team_user'
850
N/A
should
respond_with
:
success
850
N/A
end
850
N/A
end
850
N/A
850
N/A
context
'with one user'
do
850
N/A
context
'removing the last user'
do
850
N/A
setup
do
866
N/A
sign_in
@
admin
850
N/A
xhr
:
delete
, :
destroy
,
866
N/A
:
team_id
=> @
team.id
,
850
N/A
:
id
=> @
team.team_users.first.id
850
N/A
end
830
N/A
850
N/A
should
'return a helpful error message'
do
867
N/A
assert_match
/
What
the
hell
/,
response.body
58
N/A
end
892
N/A
892
N/A
should
respond_with
:
unprocessable_entity
892
N/A
end
892
N/A
end
892
N/A
892
N/A
context
'with two users'
do
874
N/A
setup
do
874
N/A
@
team_user
= @
team.team_users.create
! :
user
=> @
user
874
N/A
end
874
N/A
874
N/A
context
'setting the admin flag'
do
874
N/A
setup
do
874
N/A
sign_in
@
admin
58
N/A
xhr
:
put
, :
update
,
144
N/A
:
team_id
=> @
team.id
,
:
id
=> @
team_user.id
,
:
team_user
=> {:
admin
=>
1
}
end
should
render_template
'team_users/_team_user'
should
respond_with
:
success
end
context
'team admin deleting other user'
do
setup
do
sign_in
@
admin
xhr
:
delete
, :
destroy
,
:
team_id
=> @
team.id
,
:
id
=> @
team_user.id
end
should
respond_with
:
success
end
end
end
end