/test/functional/comments_controller_test.rb

http://scruptious-social-networking.googlecode.com/ · Ruby · 45 lines · 36 code · 9 blank · 0 comment · 0 complexity · 0bdb9422180319ef9f7505808ee57e54 MD5 · raw file

  1. require File.dirname(__FILE__) + '/../test_helper'
  2. class CommentsControllerTest < ActionController::TestCase
  3. def test_should_get_index
  4. get :index
  5. assert_response :success
  6. assert_not_nil assigns(:comments)
  7. end
  8. def test_should_get_new
  9. get :new
  10. assert_response :success
  11. end
  12. def test_should_create_comment
  13. assert_difference('Comment.count') do
  14. post :create, :comment => { }
  15. end
  16. assert_redirected_to comment_path(assigns(:comment))
  17. end
  18. def test_should_show_comment
  19. get :show, :id => comments(:one).id
  20. assert_response :success
  21. end
  22. def test_should_get_edit
  23. get :edit, :id => comments(:one).id
  24. assert_response :success
  25. end
  26. def test_should_update_comment
  27. put :update, :id => comments(:one).id, :comment => { }
  28. assert_redirected_to comment_path(assigns(:comment))
  29. end
  30. def test_should_destroy_comment
  31. assert_difference('Comment.count', -1) do
  32. delete :destroy, :id => comments(:one).id
  33. end
  34. assert_redirected_to comments_path
  35. end
  36. end