|
|
@@ -3,6 +3,12 @@ require 'test_helper' |
|
|
class ProductsControllerTest < ActionDispatch::IntegrationTest |
|
|
class ProductsControllerTest < ActionDispatch::IntegrationTest |
|
|
setup do |
|
|
setup do |
|
|
@product = products(:one) |
|
|
@product = products(:one) |
|
|
|
|
|
@update = { |
|
|
|
|
|
title: 'Lorem Ipsum', |
|
|
|
|
|
description: 'Wibbles are fun!', |
|
|
|
|
|
image_url: 'lorem.jpg', |
|
|
|
|
|
price: 19.95 |
|
|
|
|
|
} |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
test "should get index" do |
|
|
test "should get index" do |
|
|
@@ -17,7 +23,7 @@ class ProductsControllerTest < ActionDispatch::IntegrationTest |
|
|
|
|
|
|
|
|
test "should create product" do |
|
|
test "should create product" do |
|
|
assert_difference('Product.count') do |
|
|
assert_difference('Product.count') do |
|
|
post products_url, params: { product: { description: @product.description, image_url: @product.image_url, price: @product.price, title: @product.title } } |
|
|
|
|
|
|
|
|
post products_url, params: { product: @update } |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
assert_redirected_to product_url(Product.last) |
|
|
assert_redirected_to product_url(Product.last) |
|
|
@@ -34,7 +40,7 @@ class ProductsControllerTest < ActionDispatch::IntegrationTest |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
test "should update product" do |
|
|
test "should update product" do |
|
|
patch product_url(@product), params: { product: { description: @product.description, image_url: @product.image_url, price: @product.price, title: @product.title } } |
|
|
|
|
|
|
|
|
patch product_url(@product), params: { product: @update } |
|
|
assert_redirected_to product_url(@product) |
|
|
assert_redirected_to product_url(@product) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|