Basis of rails-driven app for local business
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.

49 lines
1017 B

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