Sha256: e988b53c835d3a2f91bc409478407767f1f715cb89ca0e0d8d99987220c5c8ff

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

class ProductsControllerTest < ActionController::TestCase
  setup do
    @product = Product.create(name: "aaa", category: "bbb")
  end

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

  test "should get new" do
    get :new
    assert_response :success
    assert response.body.include? ("Add")
  end

  test "should create product" do
    assert_difference('Product.count') do
      post :create, product: { category: @product.category, name: @product.name }
    end

    assert_redirected_to product_path(assigns(:product))
  end

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

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

  test "should update product" do
    patch :update, id: @product, product: { category: @product.category, name: @product.name }
    assert_redirected_to product_path(assigns(:product))
  end

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

    assert_redirected_to products_path
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bread-0.0.6 test/dummy/test/controllers/products_controller_test.rb
bread-0.0.5 test/dummy/test/controllers/products_controller_test.rb
bread-0.0.4 test/dummy/test/controllers/products_controller_test.rb