require 'test_helper'

class ItemInCartsControllerTest < ActionController::TestCase
  setup do
    @item_in_cart = item_in_carts(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:item_in_carts)
  end

  test "should get new" do
    get :new
    assert_response :success
  end

  test "should create item_in_cart" do
    assert_difference('ItemInCart.count') do
      post :create, item_in_cart: { cart_id: @item_in_cart.cart_id, item_id: @item_in_cart.item_id }
    end

    assert_redirected_to item_in_cart_path(assigns(:item_in_cart))
  end

  test "should show item_in_cart" do
    get :show, id: @item_in_cart
    assert_response :success
  end

  test "should get edit" do
    get :edit, id: @item_in_cart
    assert_response :success
  end

  test "should update item_in_cart" do
    patch :update, id: @item_in_cart, item_in_cart: { cart_id: @item_in_cart.cart_id, item_id: @item_in_cart.item_id }
    assert_redirected_to item_in_cart_path(assigns(:item_in_cart))
  end

  test "should destroy item_in_cart" do
    assert_difference('ItemInCart.count', -1) do
      delete :destroy, id: @item_in_cart
    end

    assert_redirected_to item_in_carts_path
  end
end
