teams_controller_test.rb revision 38dab3b63e2730b443590a53de93e085659efe25
577N/Arequire 'test_helper'
577N/A
577N/Aclass TeamsControllerTest < ActionController::TestCase
577N/A
615N/A should_map_resources :teams
810N/A
577N/A context 'not signed in' do
577N/A context 'on GET to index' do
577N/A setup do
577N/A get :index
577N/A end
577N/A
577N/A should set_the_flash.to(/not authorized/)
577N/A should redirect_to("root path"){ :root }
577N/A end
577N/A end
577N/A
577N/A context 'signed in' do
577N/A setup do
577N/A @user = FactoryGirl.create :user
577N/A sign_in @user
577N/A end
577N/A
577N/A context 'on GET to index without teams' do
577N/A setup do
577N/A get :index
577N/A end
577N/A
577N/A should respond_with :success
577N/A should render_template :index
577N/A should assign_to(:team_users).with{ [] }
577N/A end
577N/A
577N/A context 'on GET to new' do
577N/A setup do
577N/A get :new
577N/A end
705N/A
577N/A should respond_with :success
577N/A should render_template :new
606N/A end
606N/A
577N/A context 'with teams' do
577N/A setup do
577N/A @team = FactoryGirl.create :team,
577N/A :admin_user => @user
577N/A end
577N/A
577N/A context 'on GET to index' do
577N/A setup do
577N/A get :index
577N/A end
577N/A
577N/A should respond_with :success
577N/A should render_template :index
577N/A end
577N/A
577N/A context 'on GET to show' do
577N/A setup do
615N/A get :show, :id => @team.to_param
615N/A end
615N/A
810N/A should respond_with :success
810N/A should render_template :show
810N/A should assign_to :team_users
810N/A end
577N/A
577N/A context 'on GET to edit' do
577N/A setup do
810N/A get :edit, :id => @team.to_param
577N/A end
577N/A
577N/A should respond_with :success
577N/A should render_template :edit
577N/A end
577N/A
577N/A context 'on DELETE to destroy' do
577N/A context 'by team admin' do
577N/A setup do
577N/A delete :destroy, :id => @team.id
810N/A end
577N/A
577N/A should redirect_to("index"){ :teams }
577N/A should set_the_flash.to(/destroyed/)
577N/A end
577N/A
577N/A context 'by non-admin' do
577N/A setup do
@member = FactoryGirl.create :user
@team.users << @member
sign_in @member
delete :destroy, :id => @team.id
end
should redirect_to("root"){ :root }
should set_the_flash.to(/not authorized/)
end
end
end
end
end