Sha256: 01dfa15a7b15b50cfa791368f6a7ea0476512440cc9bda9d82cce2c61163f440
Contents?: true
Size: 1.88 KB
Versions: 8
Compression:
Stored size: 1.88 KB
Contents
require File.dirname(__FILE__) + '/../test_helper' require 'absences_controller' # Re-raise errors caught by the controller. class AbsencesController; def rescue_action(e) raise e end; end class AbsencesControllerTest < Test::Unit::TestCase main_scenario def setup @controller = AbsencesController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @request.session[:user_id] = 1000001 @first_id = absences(:one).id end def test_index get :index assert_response :success assert_template 'list' end def test_list get :list assert_response :success assert_template 'list' assert_not_nil assigns(:absences) end def test_show get :show, :id => @first_id assert_response :success assert_template 'show' assert_not_nil assigns(:absence) assert assigns(:absence).valid? end def test_new get :new assert_response :success assert_template 'new' assert_not_nil assigns(:absence) end def test_create num_absences = Absence.count post :create, :absence => {:on => '2007-06-09', :reason => 'HOLIDAY'} assert_response :redirect assert_redirected_to :action => 'list' assert_equal num_absences + 1, Absence.count end def test_edit get :edit, :id => @first_id assert_response :success assert_template 'edit' assert_not_nil assigns(:absence) assert assigns(:absence).valid? end def test_update post :update, :id => @first_id assert_response :redirect assert_redirected_to :action => 'show', :id => @first_id end def test_destroy assert_nothing_raised { Absence.find(@first_id) } post :destroy, :id => @first_id assert_response :redirect assert_redirected_to :action => 'list' assert_raise(ActiveRecord::RecordNotFound) { Absence.find(@first_id) } end end
Version data entries
8 entries across 8 versions & 1 rubygems