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.
60 lines
1.4 KiB
60 lines
1.4 KiB
require "test_helper"
|
|
|
|
class ProductsControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
logger.warn("*************SETUP*******")
|
|
puts "*************PUTS working *****************"
|
|
@product = products(:one)
|
|
end
|
|
|
|
test "should get index" do
|
|
Rails.logger.info("*************INDEX*******")
|
|
get products_url
|
|
assert_response :success
|
|
# assert_response :failure
|
|
end
|
|
|
|
test "should get new" do
|
|
get new_product_url
|
|
assert_response :success
|
|
end
|
|
|
|
test "should create product" do
|
|
assert_difference("Product.count") do
|
|
post products_url, params: { product: { price: @product.price, title: @product.title } }
|
|
end
|
|
|
|
assert_redirected_to product_url(Product.last)
|
|
end
|
|
|
|
test "should show product" do
|
|
get product_url(@product)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should get edit" do
|
|
get edit_product_url(@product)
|
|
assert_response :success
|
|
end
|
|
|
|
test "should update product" do
|
|
patch product_url(@product), params: { product: { price: @product.price, title: @product.title } }
|
|
assert_redirected_to product_url(@product)
|
|
end
|
|
|
|
test "should destroy product" do
|
|
assert_difference("Product.count", -1) do
|
|
delete product_url(@product)
|
|
end
|
|
|
|
assert_redirected_to products_url
|
|
end
|
|
|
|
test "should destroy product2" do
|
|
assert_difference("Product.count", -1) do
|
|
delete product_url(@product)
|
|
end
|
|
|
|
assert_redirected_to products_url
|
|
end
|
|
end
|