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.
 
 
 
 
 

49 lines
1.1 KiB

  1. require 'test_helper'
  2. class CategoriesControllerTest < ActionDispatch::IntegrationTest
  3. setup do
  4. @category = categories(:one)
  5. end
  6. test "should get index" do
  7. get categories_url
  8. assert_response :success
  9. end
  10. test "should get new" do
  11. get new_category_url
  12. assert_response :success
  13. end
  14. test "should create category" do
  15. assert_difference('Category.count') do
  16. post categories_url, params: { category: { name: @category.name } }
  17. end
  18. assert_redirected_to category_url(Category.last)
  19. end
  20. test "should show category" do
  21. get category_url(@category)
  22. assert_response :success
  23. end
  24. test "should get edit" do
  25. get edit_category_url(@category)
  26. assert_response :success
  27. end
  28. test "should update category" do
  29. patch category_url(@category), params: { category: { name: @category.name } }
  30. assert_redirected_to category_url(@category)
  31. end
  32. test "should destroy category" do
  33. assert_difference('Category.count', -1) do
  34. delete category_url(@category)
  35. end
  36. assert_redirected_to categories_url
  37. end
  38. end