Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

53 rader
1.1 KiB

  1. require 'test_helper'
  2. class LineItemsControllerTest < ActionDispatch::IntegrationTest
  3. setup do
  4. @line_item = line_items(:one)
  5. end
  6. test "should get index" do
  7. get line_items_url
  8. assert_response :success
  9. end
  10. test "should get new" do
  11. get new_line_item_url
  12. assert_response :success
  13. end
  14. test "should create line_item" do
  15. assert_difference('LineItem.count') do
  16. post line_items_url, params: { product_id: products(:ruby).id }
  17. end
  18. follow_redirect!
  19. assert_select 'h2', 'Your Cart'
  20. assert_select 'td', 'Programming Ruby 1.9'
  21. end
  22. test "should show line_item" do
  23. get line_item_url(@line_item)
  24. assert_response :success
  25. end
  26. test "should get edit" do
  27. get edit_line_item_url(@line_item)
  28. assert_response :success
  29. end
  30. test "should update line_item" do
  31. patch line_item_url(@line_item),
  32. params: { line_item: { product_id: @line_item.product_id } }
  33. assert_redirected_to line_item_url(@line_item)
  34. end
  35. test "should destroy line_item" do
  36. assert_difference('LineItem.count', -1) do
  37. delete line_item_url(@line_item)
  38. end
  39. assert_redirected_to line_items_url
  40. end
  41. end