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.

54 lines
1.2 KiB

  1. require 'test_helper'
  2. class EmployeesControllerTest < ActionController::TestCase
  3. def test_index
  4. get :index
  5. assert_template 'index'
  6. end
  7. def test_show
  8. get :show, :id => Employee.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. Employee.any_instance.stubs(:valid?).returns(false)
  17. post :create
  18. assert_template 'new'
  19. end
  20. def test_create_valid
  21. Employee.any_instance.stubs(:valid?).returns(true)
  22. post :create
  23. assert_redirected_to employee_url(assigns(:employee))
  24. end
  25. def test_edit
  26. get :edit, :id => Employee.first
  27. assert_template 'edit'
  28. end
  29. def test_update_invalid
  30. Employee.any_instance.stubs(:valid?).returns(false)
  31. put :update, :id => Employee.first
  32. assert_template 'edit'
  33. end
  34. def test_update_valid
  35. Employee.any_instance.stubs(:valid?).returns(true)
  36. put :update, :id => Employee.first
  37. assert_redirected_to employee_url(assigns(:employee))
  38. end
  39. def test_destroy
  40. employee = Employee.first
  41. delete :destroy, :id => employee
  42. assert_redirected_to employees_url
  43. assert !Employee.exists?(employee.id)
  44. end
  45. end