1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'rentable_controller'
4 # Re-raise errors caught by the controller.
5 class RentableController; def rescue_action(e) raise e end; end
7 class RentableControllerTest < Test::Unit::TestCase
11 @controller = RentableController.new
12 @request = ActionController::TestRequest.new
13 @response = ActionController::TestResponse.new
15 @first_id = rentables(:first).id
20 assert_response :success
21 assert_template 'list'
27 assert_response :success
28 assert_template 'list'
30 assert_not_nil assigns(:rentables)
34 get :show, :id => @first_id
36 assert_response :success
37 assert_template 'show'
39 assert_not_nil assigns(:rentable)
40 assert assigns(:rentable).valid?
46 assert_response :success
49 assert_not_nil assigns(:rentable)
53 num_rentables = Rentable.count
55 post :create, :rentable => {}
57 assert_response :redirect
58 assert_redirected_to :action => 'list'
60 assert_equal num_rentables + 1, Rentable.count
64 get :edit, :id => @first_id
66 assert_response :success
67 assert_template 'edit'
69 assert_not_nil assigns(:rentable)
70 assert assigns(:rentable).valid?
74 post :update, :id => @first_id
75 assert_response :redirect
76 assert_redirected_to :action => 'show', :id => @first_id
80 assert_nothing_raised {
81 Rentable.find(@first_id)
84 post :destroy, :id => @first_id
85 assert_response :redirect
86 assert_redirected_to :action => 'list'
88 assert_raise(ActiveRecord::RecordNotFound) {
89 Rentable.find(@first_id)