testy/test/controllers/products_controller_test.rb
Mohammad Kanaan 2cc3c1a7dd
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
initial commit
2026-05-17 14:12:43 +03:00

38 lines
933 B
Ruby

require "test_helper"
class ProductsControllerTest < ActionDispatch::IntegrationTest
setup do
@product = products(:one)
end
test "should get index" do
get products_url, as: :json
assert_response :success
end
test "should create product" do
assert_difference("Product.count") do
post products_url, params: { product: { barcode: @product.barcode, name: @product.name } }, as: :json
end
assert_response :created
end
test "should show product" do
get product_url(@product), as: :json
assert_response :success
end
test "should update product" do
patch product_url(@product), params: { product: { barcode: @product.barcode, name: @product.name } }, as: :json
assert_response :success
end
test "should destroy product" do
assert_difference("Product.count", -1) do
delete product_url(@product), as: :json
end
assert_response :no_content
end
end