require File.dirname(__FILE__) + '/../test_helper' require 'periods_controller' # Re-raise errors caught by the controller. class PeriodsController; def rescue_action(e) raise e end; end class PeriodsControllerTest < Test::Unit::TestCase fixtures :parties, :users, :groups, :groups_users, :periods, :tasks, :task_files, :works, :estimates def setup @controller = PeriodsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @request.session[:user_id] = 1000001 assert_sequences end def teardown assert_sequences end def test_index get :index assert_response :redirect assert_redirected_to :action => :show, :id => periods(:ancient).id Task.find(tasks(:in_ancient).id).abort get :index assert_response :redirect assert_redirected_to :action => :show, :id => periods(:past).id Task.find(tasks(:first).id).abort get :index assert_response :redirect assert_redirected_to :action => :show, :id => periods(:active).id end def test_show get :show, :id => 1 assert_response :success assert_template 'show' assert_not_nil assigns(:period) assert assigns(:period).valid? end def test_new get :new assert_response :success assert_template 'new' assert_not_nil assigns(:period) end def test_create num_periods = Period.count post :create, :period => {:party_id => 1, :start_on => '2007-06-11', :end_on => '2007-06-24'} assert_response :redirect assert_redirected_to :action => :show, :id => periods(:future).id assert_equal num_periods + 1, Period.count end def test_edit get :edit, :id => 1 assert_response :success assert_template 'edit' assert_not_nil assigns(:period) assert assigns(:period).valid? end def test_update post :update, :id => 1 assert_response :redirect assert_redirected_to :action => 'show', :id => 1 end def test_destroy assert_not_nil Period.find(1) post :destroy, :id => 1 assert_response :redirect assert_redirected_to :action => :index assert_raise(ActiveRecord::RecordNotFound) { Period.find(1) } end def test_burn_down_chart get :burn_down_chart, :id => 1 end end