/test/functional/comments_controller_test.rb
Ruby | 45 lines | 36 code | 9 blank | 0 comment | 0 complexity | 0bdb9422180319ef9f7505808ee57e54 MD5 | raw file
1require File.dirname(__FILE__) + '/../test_helper' 2 3class CommentsControllerTest < ActionController::TestCase 4 def test_should_get_index 5 get :index 6 assert_response :success 7 assert_not_nil assigns(:comments) 8 end 9 10 def test_should_get_new 11 get :new 12 assert_response :success 13 end 14 15 def test_should_create_comment 16 assert_difference('Comment.count') do 17 post :create, :comment => { } 18 end 19 20 assert_redirected_to comment_path(assigns(:comment)) 21 end 22 23 def test_should_show_comment 24 get :show, :id => comments(:one).id 25 assert_response :success 26 end 27 28 def test_should_get_edit 29 get :edit, :id => comments(:one).id 30 assert_response :success 31 end 32 33 def test_should_update_comment 34 put :update, :id => comments(:one).id, :comment => { } 35 assert_redirected_to comment_path(assigns(:comment)) 36 end 37 38 def test_should_destroy_comment 39 assert_difference('Comment.count', -1) do 40 delete :destroy, :id => comments(:one).id 41 end 42 43 assert_redirected_to comments_path 44 end 45end