Basis of rails driven photo website with a Flash uploader
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

54 lines
1.1 KiB

  1. require 'test_helper'
  2. class PhotosControllerTest < ActionController::TestCase
  3. def test_index
  4. get :index
  5. assert_template 'index'
  6. end
  7. def test_show
  8. get :show, :id => Photo.first
  9. assert_template 'show'
  10. end
  11. def test_new
  12. get :new
  13. assert_template 'new'
  14. end
  15. def test_create_invalid
  16. Photo.any_instance.stubs(:valid?).returns(false)
  17. post :create
  18. assert_template 'new'
  19. end
  20. def test_create_valid
  21. Photo.any_instance.stubs(:valid?).returns(true)
  22. post :create
  23. assert_redirected_to photo_url(assigns(:photo))
  24. end
  25. def test_edit
  26. get :edit, :id => Photo.first
  27. assert_template 'edit'
  28. end
  29. def test_update_invalid
  30. Photo.any_instance.stubs(:valid?).returns(false)
  31. put :update, :id => Photo.first
  32. assert_template 'edit'
  33. end
  34. def test_update_valid
  35. Photo.any_instance.stubs(:valid?).returns(true)
  36. put :update, :id => Photo.first
  37. assert_redirected_to photo_url(assigns(:photo))
  38. end
  39. def test_destroy
  40. photo = Photo.first
  41. delete :destroy, :id => photo
  42. assert_redirected_to photos_url
  43. assert !Photo.exists?(photo.id)
  44. end
  45. end