Sha256: 910f9a665541c84b0910c831cdf6ec4b6ec37710d0daeb9d0b9f633a2f2f6e9d

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'

class ItemsControllerTest < ActionController::TestCase
  setup do
    @item = items(:one)
  end

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

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

  test "should create item" do
    assert_difference('Item.count') do
      post :create, item: { name: @item.name, price: @item.price, qty: @item.qty }
    end

    assert_redirected_to item_path(assigns(:item))
  end

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

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

  test "should update item" do
    patch :update, id: @item, item: { name: @item.name, price: @item.price, qty: @item.qty }
    assert_redirected_to item_path(assigns(:item))
  end

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

    assert_redirected_to items_path
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
simple_cart-0.0.5 spec/dummy/test/controllers/items_controller_test.rb
simple_cart-0.0.4 spec/dummy/test/controllers/items_controller_test.rb
simple_cart-0.0.3 test/dummy/test/controllers/items_controller_test.rb
simple_cart-0.0.2 test/dummy/test/controllers/items_controller_test.rb