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.
 
 
 
 
 

55 lines
1.1 KiB

  1. require 'test_helper'
  2. class ProductsControllerTest < ActionDispatch::IntegrationTest
  3. setup do
  4. @product = products(:one)
  5. @update = {
  6. title: 'Lorem Ipsum',
  7. description: 'Wibbles are fun!',
  8. image_url: 'lorem.jpg',
  9. price: 19.95
  10. }
  11. end
  12. test "should get index" do
  13. get products_url
  14. assert_response :success
  15. end
  16. test "should get new" do
  17. get new_product_url
  18. assert_response :success
  19. end
  20. test "should create product" do
  21. assert_difference('Product.count') do
  22. post products_url, params: { product: @update }
  23. end
  24. assert_redirected_to product_url(Product.last)
  25. end
  26. test "should show product" do
  27. get product_url(@product)
  28. assert_response :success
  29. end
  30. test "should get edit" do
  31. get edit_product_url(@product)
  32. assert_response :success
  33. end
  34. test "should update product" do
  35. patch product_url(@product), params: { product: @update }
  36. assert_redirected_to product_url(@product)
  37. end
  38. test "should destroy product" do
  39. assert_difference('Product.count', -1) do
  40. delete product_url(@product)
  41. end
  42. assert_redirected_to products_url
  43. end
  44. end