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.
 
 
 
 
 

52 lines
1.0 KiB

  1. require 'test_helper'
  2. class CartsControllerTest < ActionDispatch::IntegrationTest
  3. setup do
  4. @cart = carts(:one)
  5. end
  6. test "should get index" do
  7. get carts_url
  8. assert_response :success
  9. end
  10. test "should get new" do
  11. get new_cart_url
  12. assert_response :success
  13. end
  14. test "should create cart" do
  15. assert_difference('Cart.count') do
  16. post carts_url, params: { cart: { } }
  17. end
  18. assert_redirected_to store_index_url
  19. end
  20. test "should show cart" do
  21. get cart_url(@cart)
  22. assert_response :success
  23. end
  24. test "should get edit" do
  25. get edit_cart_url(@cart)
  26. assert_response :success
  27. end
  28. test "should update cart" do
  29. patch cart_url(@cart), params: { cart: { } }
  30. assert_redirected_to cart_url(@cart)
  31. end
  32. test "should destroy cart" do
  33. post line_items_url, params: { product_id: products(:ruby).id }
  34. @cart = Cart.find(session[:cart_id])
  35. assert_difference('Cart.count', -1) do
  36. delete cart_url(@cart)
  37. end
  38. assert_redirected_to store_index_url
  39. end
  40. end